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
1 answer

Is ReentrantLock Facade design pattern implementation?

I am learning design patterns, and after going through the text book examples, I am focusing on JDK implementation of design patterns. ReentrantLock class in java.concurrent.Lock package use AbstractQueueSynchronizer(AQS) for providing locking…
AKS
  • 1,393
  • 3
  • 19
  • 29
0
votes
1 answer

How to read data concurrently using java?

I have a method which takes a string as input and returns data from the DB based on the input string. I have an array of strings and I am currently passing each string as input and looping over the entire array public DataClass getData(String…
user811433
  • 3,999
  • 13
  • 53
  • 76
0
votes
2 answers

Java: Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException

i am currently trying to code my own little 2D Game. It's a Helicopter dodging rockets. these rockets flighing from right to the left. If they are outside of the Panel they should be deleted. this is how it looks like: private void doLogic() { …
0
votes
1 answer

Do i need to call Platform.runLater for updating UI if i'm working on JavaFX Application Thread

Do i need to create a new Runnable object and run Platform.runLater if i'm still working on JavaFX Application Thread for updating UI. For example, i need to update a Text object which is imported in Controller Class from a fxml file, and i will…
quartaela
  • 2,579
  • 16
  • 63
  • 99
0
votes
3 answers

how to maximize resource (RAM and CPU) usage with multi-threaded java programming?

my code is running on a 32-bit JVM (JRE v1.6) on Windows 2008 Server (64-bit) with 128 GB of RAM and 64 cores. however, the maximum heap space i can ever specify is 1.5 GB. my code looks the following. int numThreads =…
Jane Wayne
  • 8,205
  • 17
  • 75
  • 120
0
votes
2 answers

ConcurrentHash map with Weak Reference

I am stuck in a problem and really need some help to go through this In my application. I have a ConcurrentHashMap where multiple can thread can store or retrieve data simultaneously. To solve this issue I have chosen. Now the problem after certain…
Souvik
  • 1,219
  • 3
  • 16
  • 38
0
votes
2 answers

Non volatile status flag in multi-threaded code

I am a novice when it comes to concurrency and unsure of myself when spotting issues, I was looking through a fairly established code base and found the following code (edited for brevity) which I believe to be susceptible to data races: public…
bluth
  • 481
  • 1
  • 5
  • 10
0
votes
1 answer

ConcurrentLinkQueue implementation going into deadlock

I am learning concurrent programming and wrote this concurrentLinkeQueue using AtomicReference. Following Example goes into Deadlock. Please see. package concurrent.AtomicE; import java.util.concurrent.atomic.AtomicReference; public class…
0
votes
2 answers

Best way to code for Java 7 task required other task to finish first

I have one task that I start off immediately, various executors that run, but then I have a final task that must not run until the the first task has finished. I am some knowledge of concurrency, but things change so much I'm unsure what is the now…
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
0
votes
1 answer

Accumulating a volatile var in a loop while reporting its value every second doesn't produce expected results

This code is a simplification of other code that does useful things. To track progress of a loop, I am accumulating a volatile var count inside the loop and reporting the value of the count using a scheduled thread from Java concurrent. def foo { …
Lance Gatlin
  • 193
  • 2
  • 9
0
votes
2 answers

How to specify the type of threads between which an exchange takes place using an exchanger?

I have two Runnable classes, Reader and Writer. import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; import java.util.concurrent.Exchanger; public class Reader implements Runnable { private static final int…
JavaNewbie_M107
  • 2,007
  • 3
  • 21
  • 36
0
votes
2 answers

Thread synchronization when using BlockingQueue

I am trying to process some messages that I get from an MQ infrastructure.I have two blocking queues,sharedQueue and pubQueue. The sharedqueue gets filled up with the messages that I get from the MQ infrastructure as below.It will put the messages…
Tito
  • 8,894
  • 12
  • 52
  • 86
0
votes
1 answer

Which java concurrent to use for cleaning DB (on demand/scheduled)

I have a thread cleaner in my code that is being created if the DB capacity was exceeded, the capacity is checked on every insertion to the DB. I would like to add more functionality to this cleaner and clean also when number of files exceeding,…
Snow
  • 339
  • 1
  • 5
  • 20
0
votes
2 answers

How to cancel associated Runnables when CountDownLatch.await() is interrupted

I'm using a java.util.concurrent.CountDownLatch object (latch) to control a set of Runnables which get executed via a thread pool (which could also be executing other Runnables). In certain (and desirable) instances, the main thread is interrupted…
Bathsheba
  • 231,907
  • 34
  • 361
  • 483
0
votes
2 answers

Does JVM know anything about java.util.concurrent package?

Below in try block, there are 3 statements must be executed in that order. Is there any possibility that statements could run out of order? Does JVM look ahead in j.u.c classes to see synchronization indicators (synchronized, volatile) and figure…
mert inan
  • 1,537
  • 2
  • 15
  • 26