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
0
votes
6 answers

Which Java collection classes are better to use in multi-thread environment

Hi I am new for working on Java multi thread environment. I have to add,update and remove the set of objects in collection at one thread. And at this same time I going to check and iterate the object at another thread. List and set are not thread…
0
votes
3 answers

Java concurrent: choose synchronized collection

I want concurrently do the next things: Add new item at the end of collection (often) Remove item (or few items) from the begining of collection (often) Remove item (or few items) from the middle of collection (rarely, happens by iterating all…
VB_
  • 45,112
  • 42
  • 145
  • 293
0
votes
0 answers

FIFO for Write Order in ConcurrentHashMap

My CHM already contains following Data -> 1 Apple 2 Banana 3 Cat 4 dog 1,2,3,4 are keys and Apple, banana... are keys correspondingly. If 3 threads t1, t2, t3 wants to modify the same existing record [3 Cat] . I need this write in FIFO…
0
votes
0 answers

Processing Before and after tasks are scheduled in ScheduledThreadPoolExecutor

I am using http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html to process different tasks in my app. However, I wanted to carry out certain things (say tracking task start/completion time) before a task has…
user243655
  • 7,749
  • 8
  • 30
  • 33
0
votes
1 answer

Java Concurrent - Thread synchronization in Fork/Join - LU decomposition

During developing a Java software, I asked here Java Concurrent - no speedUp gained LU algorithm - False sharing? why I don't have no speed up parallelizing this code using CyclicBarrier. public void decompose(){ int n = A.length; for(int…
0
votes
1 answer

java.util.concurrent: Transition from Runnable to Executor interface

I am writing a JUnit test case for a DSL, and I need to ensure that the method under test does never end (as in this question). The provided solution is fine, but I would like to use the "new" Executor interface (Java 5.0 onwards): @Test public void…
0
votes
1 answer

Synchronizing three steps in three different threads?

In my main programme, i start three threads as described below Thread 1:- having steps 1A and 1B Thread 2:- having steps 2A and 2B Thread 3:- having steps 3A and 3B I want Thread 1, 2 and 3 proceed for their next step only when all of them complete…
M Sach
  • 33,416
  • 76
  • 221
  • 314
0
votes
1 answer

java.lang.NoClassDefFoundError: edu/emory/mathcs/backport/java/util/concurrent/BlockingQueue

I am working with SWTBot, and created a plugin in order to test my application's GUI. At the point i have been able to initiate the bot, but i am not getting the following exception when testing the product: java.lang.NoClassDefFoundError:…
GGomes
  • 11
  • 1
  • 7
0
votes
2 answers

Java compareAndSet to atomically update references in a BST

In a binary tree, I'm trying to atomically replace left child of parent to a new node. In the below method, pnode.left is pointing to node and I'm trying to change it to replaceNode. In line1, childPtr is pointing to pnode.left In line2, oldChildPtr…
0
votes
1 answer

future.get after ScheduledThreadPoolExecutor shutdown, will it work?

We use the ScheduledThreadPoolExecutor and after submitting the job we call shutdown immediately. Because as per doc Shutdown does not kill the submitted task, running task and allows it to complete. The question is after shutdown can we continue…
0
votes
1 answer

multithreading to calculate primes java

I am trying to parallelize a prime number counter as an exercise. I have refactored the original code and separated the long loops from others so that I can parallelize them. Now I have the following code and multithreading is looking difficult as…
0
votes
1 answer

Java Monitors -- Catching InterruptedException

I have a java implementation of a monitor using java.util.concurrent.locks.Lock; java.util.concurrent.locks.ReentrantLock; java.util.concurrent.locks.Condition; The problem that I'm solving is a readers/writers problem. I have one lock lock & two…
0
votes
2 answers

How to concurrently modify a Vector

I have to ensure while iterating the Vector; there is no update on that Vector to avoid ConcurrentModificationException. I can use concurrent collection. But i just want to give a try on Vector. Below is the code I have written. public class…
0
votes
4 answers

If I simply need to guarantee `happens-before` relation, and not atomicity, should I use a concurrent class or a synchronized block?

I am developing a pool mechanism. Objects in the pool will be used by different threads. Thus I need to guarantee that there will be a happens-before relation when accessing non-final attributes of these objects. As a given object will be accessed…
FBB
  • 1,414
  • 2
  • 17
  • 29
0
votes
1 answer

Multiple Threads spawning multiple threads and how to wait for child Threads

I have two arrays abc[100] and def[1000] and I have to find an array xyz[100] , where xyz[i] = minDistance(abc[i],def) i.e for every element in abc i have to find a corresponding nearest element in def and set in xyz. For this I am using threads…
Abhilash
  • 377
  • 1
  • 3
  • 13