3
votes
0answers
22 views

Matrix multiplication project using multithreading in java

Below is my code of matrix multiplication in Java. It has both implementation of matrix multiplication- one without multi-threading and another one using multi-threading. For multi-threading ...
1
vote
0answers
51 views

Parallel matrix multiplication in Java with streams

This StackOverflow post highlights how to do matrix multiplication using Java's stream. With Java streams, there is a new way to enable concurrent threading with the Java's parallel stream. ...
7
votes
0answers
140 views
+100

Do not share same socket between two threads at the same time

I have a code in which I am dealing with sockets and I need to make sure that I don't share same socket between two threads. In my below code, I have a background thread which runs every 60 seconds ...
0
votes
0answers
20 views

How to unblock input.readLong() (java multithreaded socket) [closed]

Screenshot of current results (Server on left) (Client on right): https://www.dropbox.com/s/lb81651txq6yuxy/aaascreenshot.png?dl=...
2
votes
2answers
95 views

Simple yet threadsafe file cache in java

I'm attempting to cache contents of a file to avoid frequent reads, using a very simple implementation in a single class. The file contains a list of emailids, one per line. The file changes rarely, ...
8
votes
2answers
103 views

Hotel power management

A Hotel needs to reduce the overall power used by the equipments installed in its many floors. So the Hotel Management has installed sensors, like Motion Sensors, etc at appropriate places .I have to ...
1
vote
1answer
47 views

Acquiring multiple resource exclusively before processing using lock and monitor in JAVA

Here is my implementation of an all-or-wait-until-all kind of process. Each thread (kid) needs to guarantee it is the only thread processing the required resources (toys) at that moment. If some ...
3
votes
1answer
71 views

Port Availability Scanner, written in Java (9)

For purpose of practice and experience, I was working on a "Port Availability Scanner" written in Java. So far it's working but it's really slow. Especially on relatively large quantities of ports (...
0
votes
1answer
43 views

Synchronous access to queue

I have a requirement where I will hit a link and get a response. The response is an XML data containing child links. The response is then copied to a file and the child links are added to a queue ...
2
votes
1answer
54 views

Parallel curvesort in Java

What? I have designed curvesort, an algorithm that adapts to "smoothness" of data. For example, if the data resembles a sine wave, it is likely that curvesort will sort it fast. This post is about a ...
1
vote
1answer
27 views

Combining multiple files using a single server in Java

I have ~50 files, each file contains records that look like the following: ...
2
votes
1answer
166 views

Java Concurrent Multimap

I've implemented a concurrent multimap that support concurrent put and remove but I'm unsure of its correctness. I would appreciate your feedback. ...
2
votes
2answers
42 views

Read file with URLs to connect to them, search for patterns and generate output in multi-threading env

I've been implementing a little application that will read a text file that holds URL addresses (one address per line). Example: ...
4
votes
2answers
108 views

Counter GUI in Swing, updating the count in the background

I made a simple counter GUI for practice. The user presses a button to start the counter. The button click executes a SwingWorker task that updates a JLabel with ...
2
votes
1answer
68 views

Processing files in directories with multithreading

I am processing files in directories. I want to use multi-threading in two ways: 10 threads to process files/folders concurrently 10 threads to process all lines in each file concurrently In this ...
2
votes
0answers
47 views

Threadsafe static initialization of ExecutorService

I am trying to create a threadsafe singleton class based on Initialization-on-demand holder idiom . Here is my code ...
1
vote
2answers
65 views

Run code every n invocations

I came across a situation where I needed code to run every n invocations of a method. Specifically, I was clearing out massive amounts of data and needed to hint ...
5
votes
1answer
95 views

Message Queue for inter-thread communication

I wrote this little piece of code, a while back. The intention behind it was to create a system to send messages between consumer and producer threads. I have no idea for what i wanted to use it. I ...
1
vote
0answers
62 views

Synchronous cinema hall, with StampedLock

I'm beginner in Java concurrency mechanism. I wrote some application to train a synchronization between many threads. I noticed that I wrote a lot of if statements, and it looks really ugly. Maby is ...
1
vote
0answers
44 views

MVC web app writing to file in a threadsafe way

This is as much a code design question as a code review. I am adding some temporary code to my website to record search terms used. For now I'm also storing a few other fields. This is an ...
4
votes
3answers
174 views

Producer-Consumer with Peterson algorithm in java

Producer-consumer problem in Java with a circular buffer of N positions. There is a single thread representing the producer that will produce consecutive integer elements There is a dimensioned ...
1
vote
1answer
171 views

Using 2 threads to compute the nth Fibonacci number (with memoization)

If the 5th Fibonacci number has to be computed, I'm trying to split the 2 recursive trees into 2 threads: ...
4
votes
1answer
47 views

Implement Custom Google Guava Splitter Class

Problem : Create a thread safe class Spliiter that divides strings into substrings, by recognizing a separator which can be expressed as a single character, literal ...
1
vote
1answer
95 views

Multithreaded telnet chat server in Java

I have writed a multithreaded telnet chat application in Java. In main method I run telnet server. In server class at run method I bind in specified port (8189) and I spawn listener threads for every ...
2
votes
0answers
36 views

A multi-threaded key-value cache that only has thread contention while querying for same key simultaneously

Maybe the title fails to make myself clear, more explanation to the requirements: Implement a thread-safe key-value cache. User of this cache will use an unique key to query for data. If the data is ...
0
votes
0answers
34 views

How to ensure there is one Executor

I am using Socket.IO-java on the desktop application to handle realtime communication with the server. I was wondering if I could get some feed back on the setup as I am not happy with how it's done, ...
5
votes
1answer
601 views

Java Matrix multiplication using Multithreading

I am trying to achieve matrix multiplication using the concept of concurrency and cyclic barrier. Here is the code snippet:- ...
1
vote
0answers
60 views

Get/Set the value in the cache using the AtomicReference in Java

I have this code which gets and sets the data in the cache using the synchronized block. I want to know if is there is any way by which I can remove the synchronized...
0
votes
0answers
137 views

BlockingQueue with unique elements in Java

This answer on Stack Overflow includes an implementation for a Java BlockingQueue with unique elements. I changed it and included it in a project: ...
5
votes
3answers
185 views

Concurrently reading a Map while a single background thread regularly modifies it

I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside ...
1
vote
0answers
48 views

Two priests talking to one another

It's a part of code where two Threads ("priests") talk to each other. One asks and waits for the second to answer - then something happens depending on what has been answered by second thread. I ...
1
vote
0answers
93 views

Sync SQLite databases using threads and a Service

I have an Android app that collects data in n number of SQLite databases. The user decides the value of n in runtime. A Service is in charge of sending that data to our server. We used to do this with ...
1
vote
2answers
52 views

Simplified LogService (from concurrency in practice) with shutdown feature

Brian Goetz provided following code of LogService with shutdown feature: ...
2
votes
1answer
49 views

Parse the response from http call and populate multiple maps

I have to parse a response after making HTTP call on the server. If the response is not successful then try another server otherwise parse the successful response and populate two ...
9
votes
2answers
107 views

Java queue with dynamic priority flag

I need to build a queue where the elements will be added and removed in chronological order by default. But if the client sets the priority flag for the queue I need to be able to pull the elements ...
3
votes
0answers
45 views

Partition numbers as polynomial, each number in a thread

I'm beginner at multithreading programming and I wanna write a piece of my code using it. I'm trying to split different numbers into multiple parts and store them as a polynomial. I wanna do this ...
2
votes
0answers
38 views

Asynchronous service that publishes a possibly infinite amount of events

I want to implement a service that fetches eyetracking events and publishes them to all subscribers of the stream. The whole thing is supposed to run asynchronously, so it doesn't block the UI thread. ...
4
votes
2answers
102 views

Multithread the variant of matrix multiplication

This is matrix multiplication. Big matrix split on the submatrix and multiplication in parallel, result matrices merge to result. How i can make this code better? ...
2
votes
2answers
529 views

Running multiple producer and single consumer in a multithread environment

I have a below class in which add method will be called by multiple threads to populate messageByChannelReference concurrent ...
0
votes
1answer
54 views

Model for starting a thread with an initial value, pausing, resuming with a new value and stopping a thread

Here is a design to achieve a simple model in Java which uses a Thread and has these features: Starting the thread with an initial value Pausing the thread ...
2
votes
2answers
132 views

ASCII to Binary and reverse in java

Here is a simple app that i am trying to implement in java. my goal is to write a program that can convert ASCII to Binary and back. Questions: Am i violating any OOP Rule. Is my code readable ? ...
5
votes
3answers
458 views

Brute-force Vigenere Cipher using multiple threads

I'm trying to brute force a Vigenere Cipher knowing only that the key length is 5+ characters and that the decrypted text has the word ...
2
votes
1answer
127 views

Loading interstitial adMob in different threads

I want to load Interstitial AdMob after 5 second, after the Activity started, in another Thread. Is this code right, or I'm duplicating ...
0
votes
2answers
207 views

FutureTask in Android, wait for a thread to execute the next one

This code is executed on a background service every 60 seconds on an Android app. Each class instantiated on FutureTask (WifiInfoFetch and WifiApResults) contains an insert to an SQLite database. We ...
0
votes
1answer
80 views

Caching wrapper for digest computation

I need to review this code: ...
2
votes
0answers
52 views

Concurrent ObjectPool using ConcurrentLinkedQueue

Main ObjectPool Class: It uses atomic operations and a concurrent linked queue to achieve the best performance compared to Apache commons pool. I want to make sure there are no concurrency issues even ...
4
votes
1answer
86 views

Multi-threaded code to handle messages from a provider

Having a look at my code, is there a way to be losing elements? ...
0
votes
0answers
53 views

Queue that permits at most X simultaneous operations

I ran into this once (permits=N) and then again today (permits =1) where I only want 1 to N operations running simultaneously. One example comes from firing into a state machine (the permit=1 example)...
0
votes
0answers
28 views

Thread handling for playing videos

This is a simple motion detection using webcam written in Java, based on this example. Basically, what this code does is: While no motion is detected, play a 'blank video' in loop. Every time a ...