12
votes
2answers
100 views

java.util.concurrent bounded resuable resource implementation

I'm trying to code following requirements with lockfree in most-used-code-path that is to get a resource from pool. Same resource should be used n (maxUsageCount) ...
12
votes
2answers
210 views

Can I make the thread safe case faster?

The code below is part of one of my projects called largetext, which actually stemmed from a question on StackOverflow. The goal is to provide access to a very large text file as a ...
10
votes
4answers
633 views

Concurrent multi-server pinging in Java

I have an application that essentially "pings" all of the servers on my network. I have about 100 servers, and this ping will happen every 10 seconds. ...
10
votes
2answers
72 views

Poke-a-Dot (Provider)

I need to create variable-length strings of dots/periods/full-stops to add to some text content, in a way that is similar to a formatted table-of-contents: ...
9
votes
2answers
129 views

Concurrent task processing queue

I can have a maximum of three concurrent threads processing tasks. Each of these threads can process 1 to 100 tasks simultaneously (by connecting to an external system). The time taken to process 100 ...
8
votes
1answer
188 views

Cache<Long, BlockingDeque<Peer>> combined with Striped<ReadWriteLock>: is it thread-safe

I've implemented PeersContainer class with all operations that I need. I need something like multimap in concurrent environment, moreover I need remove entities ...
5
votes
2answers
258 views

Producer/Consumer implementation

I am using Netty embedded within Grails to process and display incoming SNMP messages. Since Netty 4 doesn't come with a built-in ChannelExecutionHandler I had to ...
5
votes
3answers
121 views

Feedback on thread safety of the classes

I have following classes. Are they properly guarded for thread safety? Do you see any issues with any of the classes? ...
5
votes
2answers
55 views

Queue that connects multiple producers and multiple consumers

The scenario is about processing 'Message' objects. Producer creates them and Consumer does the consumption. ...
4
votes
2answers
111 views

Double checked locking 101

I've found a peace of code I've wrote not long ago. It is used to fetch some dictinary from DB table only once and then return it to requestors. Seems like I tryed to implement double-checked locking ...
4
votes
1answer
696 views

Unit test an ExecutorService in a deamon

To execute tasks sequentially with a timeout I use ExecutorService.submit() and Future.get(). As I don't want to block calling ...
3
votes
1answer
40 views

Concurrent non-blocking refresh

In my application there is a "config" object that is accessbile by multiple threads concurrently. It is a single object (singleton) injected by the DI in the "dependents". Until now, this (the ...
2
votes
1answer
64 views

Decoding big text input: potential concurrency bugs?

The code here will be directly pasted from this project. Quick summary: it is related to a Stack Overflow question. So, basically, all the code below aims to implement ...
2
votes
2answers
136 views

Testing an Executor

I have written the following Executor: ...
1
vote
2answers
80 views

Am I risking a deadlock in this manner of re-queueing up events?

I have a DelayQueue in Java, which multiple threads will read from. They will then perform a task, and call a requeue method which performs some mathematical logic ...
1
vote
2answers
55 views

SynchronizedArrayList implemented using reader writer synchronization

I am trying to understand the workings of reader writer locks. For the sake of learning, I implemented reader writer synchronization by my own. I implemented ...
1
vote
2answers
114 views

Is that correct example of unsafe publication in java? [closed]

There are many examples of unsafe publication on the web. But I cannot find a complete program for reproducing it. I wrote an example but I do not sure whether it correct or not. And in case of ...
1
vote
2answers
1k views

ReentrantReadWriteLock lock upgrade method

I have a question about lock upgrading.Specifically what bothers me is between readlock.unlock() and following writelock.lock()... I am providing a nearly complete implementation for a sample cache.I ...
1
vote
2answers
724 views

Producer-Consumer using low level synchronization

I saw a tutorial from a site where it showed the use of ArrayBlockingQueue as a thread-safe concurrent data-structure . Just for learning purposes , i tried to ...
1
vote
2answers
5k views

Reading output from multiple threads and writing to a file

There are 10 threads and I have 15 tasks. Now I have submitted all these tasks to these threads. I need to write all these threads output to a file which I was not successful. I am getting output by ...
0
votes
2answers
102 views

Continually process results of multi-thread worker [closed]

Let's say we've got some SQL queries and want to display the results. Processing takes some time, so I do it multi-threaded. The following works quite well for me. I reduced the code to the important ...