Questions tagged [java.util.concurrent]

Java package which contains utility classes commonly useful in concurrent programming. This package includes a few small standardized extensible frameworks, as well as some classes that provide useful functionality and are otherwise tedious or difficult to implement.

java.util.concurrent is a core Java package which contains utility classes commonly useful in concurrent programming. This package includes a few small standardized extensible frameworks, as well as some classes that provide useful functionality and are otherwise tedious or difficult to implement.

Main components include:

  • Executors
  • Queues
  • Timing
  • Synchronizers, Semaphores, CountDownLatch
  • Concurrent Collections

More information is available at the JavaDoc description

1396 questions
-1
votes
2 answers

What are disadvantages of using ThreadPoolExecutor as queue?

For conventional Producer-Consumer problem, we can use ExecutorService as queue. What are disadvantages of it? Is it less efficient? Because creation of thread is costly. executor = Executors.newFixedThreadPool(90); // This will be called many times…
Nilesh
  • 2,089
  • 3
  • 29
  • 53
-1
votes
2 answers

Why my cyclicBarrier is null?

Im learnign about ciclycbarrier and im trying to create a little app. The constructor of my app is the follow: public FileDownloader(String line, int maxDownload){ this.position = 0; this.line = line; this.maxDownload = maxDownload; …
-1
votes
1 answer

fast non-lock hashmap or hashmap in Java?

I am looking for a fast implementation that support multiple threads for storing mapping from integers to integers or double. I have tried ConcurrentHashMap but are not impressed with the speedup factor. I also think that I could implement one by…
-1
votes
1 answer

Multiple DB connections and executor framework

I am working a project where we fetch a list of users who are accessing a DB, we are having around 250 servers and DB count might be around 1000. I am planning to use a connection pool using DBCP and Executor framework for multi-threading. Kindly…
-1
votes
1 answer

ExecutorService working fine with submit but throwing error for invokeAll

My code is working with submit() of callable to ExecutorService. But when I tried to change it to invokeAll(), I am getting compilation error. code: public class FutureDemo{ public FutureDemo(){ ExecutorService service =…
Ravindra babu
  • 37,698
  • 11
  • 250
  • 211
-1
votes
2 answers

How to move continuous data in to the files for every 15 minutes using java

There will be data coming continuously from x device i need to move them in to files for every 15minutes please share some ideas how we can do this one in java.
-1
votes
1 answer

Refresh TextView in Android

I try to refresh TextView in Android. I am using ExecutorService in my code. When I pushed the "Start refresh" button, after several seconds my app has been stopped by Android system. I have read several topics in stackoverflow.com, but I still…
Alex
  • 751
  • 1
  • 9
  • 28
-1
votes
2 answers

Exception in thread "main" java.util.ConcurrentModificationException (Head first java book example)

I tried to run a example from Head first java book - second edition (page 152). Its a game puzzle. Which targets Dotcoms(string) in grid to sunk them. But when I tried to run this puzzle I got an Java.util.concurrentModificationException error. I…
-1
votes
1 answer

AEM CQ - System.currentTimeMillis() returning repeated results

I'm working on a AEM project, and I have a component X. Along this component, I have another one which is a container of X. So, I can drag X instances and drop them onto the container. To avoid problems between multiple instances of the component X,…
Perimosh
  • 2,304
  • 3
  • 20
  • 38
-1
votes
1 answer

Concurrency Future - is get() called if its already done?

Using a Future like this: public class Foo implements Future{ boolean done=false; public boolean isDone(){ return done; } public Object get(){ done = true; return "hi"; } } is get() called twice anyhow?
Grim
  • 1,938
  • 10
  • 56
  • 123
-1
votes
1 answer

Java Synchronizers

Scenario - A Queue has message objects. The queue is polled and messages are passed to message handlers. The message retrieval (poll) should be halted on client login event (one or more). I could use a wait/notify mechanism to achive this, but the…
-1
votes
2 answers

Why is wait inside of synchronized?

Why is wait() inside of a synchronized block? I mean, only one thread will enter the synchronized block, so how can the other thread execute the wait() instruction?
As As
  • 2,049
  • 4
  • 17
  • 33
-1
votes
2 answers

Why BlockingQueue is implemented using Array?

Why I think ArrayBlockingQueue implementation doesn't make sense - A queue always adds at the end and removes from the front. Which means a linked list would be the most efficient data-structure to implement it. Queue items are never accessed…
Bhushan
  • 2,256
  • 3
  • 22
  • 28
-1
votes
2 answers

java.util.ConcurrentModificationException while adding elements?

I have a servlet which uses a service to parse a YAML file. but when I put some user traffic on my servlet I get: SEVERE: Servlet.service() for servlet [SitesController] in context with path [] threw exception…
tokhi
  • 21,044
  • 23
  • 95
  • 105
-1
votes
1 answer

Java: Synchronizing clearing of a map while another thread could be writing into it

I have a code like this: public class SomeClass { private ScheduledExecutorService executor; private ScheduledFuture future; private Set keys; private ConcurrentMap map; public void startTask() …
izstas
  • 5,004
  • 3
  • 42
  • 56