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

Executors.newFixedThreadPool - issue

I have used CopyOnWriteArrayList collection object which holds 1000 URLs. each URL indicates a file. I want to use Multithread pooling mechanism to download those URL files parallel. Tried using below code : CopyOnWriteArrayList fileList…
Molay
  • 1,154
  • 2
  • 19
  • 42
0
votes
2 answers

How to check if a thread was born?

I created a utility class for getting info about the running threads. one thread called MQTT_THREAD starts when a button is pressed. and i have another button named play, when pressed it should check first if the thread MQTT_THREAD exists or not or…
rmaik
  • 1,076
  • 3
  • 15
  • 48
0
votes
0 answers

Multithreaded test to test response time of sites/web services

Below code tests the response time of reading www.google.com into a BufferedReader. I plan on using this code to test the response times of other sites and web services within intranet. Below tests runs for 20 seconds and opens 4 requests per second…
blue-sky
  • 51,962
  • 152
  • 427
  • 752
0
votes
1 answer

Why is CopyOnWriteArrayList different than iterating over unmodifiableList?

I am not able to understand why can't we achieve by just iterating over an immutable list rather than using this new implementation?
AKS
  • 1,393
  • 3
  • 19
  • 29
0
votes
2 answers

ConcurrentSkipListSet, add method is failing in Java 8

Pending ConcurrentSkipListSet getting fixed (http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8060435), my brain is failing trying to come up with a work around. Anyone else having problems with it in Java 8? The add method worked fine in Java 7…
Phil Freihofner
  • 7,645
  • 1
  • 20
  • 41
0
votes
1 answer

Cache with long running computations of values

I need to store objects in a cache and hese objects take a long time to create. I started with ConcurrentHashMap> and everything was fine, until Out of Memory started to happen. Moved to SoftReferences and it was better, but now…
Ricardo Marimon
  • 10,339
  • 9
  • 52
  • 59
0
votes
2 answers

Processing the collection concurrently in java

I am using the following code fragment to process the java collection concurrently. Basically i am using the TaskExecutors to process the collection in multiple threads that check for the duplicate transaction in the collection based on the…
Mayuran
  • 669
  • 2
  • 8
  • 39
0
votes
2 answers

Interrupt current thread inside run() doesn't throw InterruptedException

I made a simple function to test interrupt() & InterruptedException in Java: public static void main(String[] args) { checkInterrupt(); } private static void checkInterrupt() { Runnable runMe = new Runnable() { @Override …
0
votes
1 answer

does each instance of class has thread pool

I have class A, and there will be multiple instance of the class at run time. Does each instance create 5 threads with the below code? public class A { private void someMethod1(){ getPool(); } private static ExecutorService getPool() { …
0
votes
2 answers

Best way to search a content ( specific ID ) from a huge file ( contains 10 millions of lines ) by using java

I have a huge file containing at least 10 millions of lines and I need to search a particular unique word (ID) from that file using java. Please suggest me the best and fastest way which will consume very less processing time to achieve this. Is…
0
votes
1 answer

Parallel processing of List in java

I have a list of objects with list size of 500K. Each object in the list have a unique identifier. I want to validate the list for any duplicate objects(having the same identifier) and mark them with a flag. Since there are lot of elements in the…
Mayuran
  • 669
  • 2
  • 8
  • 39
0
votes
1 answer

CyclicBarrier misunderstanding

I tried to run example with CyclicBarrier from one of tutorials: Service man should fill empty printers when the queue of empty printers is 3. But when I ran the code it appears that printers are filled with 2, 3 or 4 empty printers in the…
Jack
  • 435
  • 2
  • 6
  • 16
0
votes
1 answer

Use of WorkManagr API in J2EE application is viable?

J2EE specification says its not advisable to create or spawn user defined threads into application logic. The reason as i understood is to avoid resource contention, synchronization issues and memory leaks. But it also suggest to use…
user1556622
0
votes
1 answer

JAVA: Execution Order between Callables submitted to ExecutorService and Threads Outside of the ExecutorService

A simplified version of what I am build has the following: A pool of threads (an ExecutorService), containing threads, each of which Sends an request message onto a server Waits for a the request fullfiled by continous checking on a shared data…
Stochastika
  • 305
  • 1
  • 2
  • 14
0
votes
1 answer

How to get tailMap for ConcurrentHashMap?

I am using TreeMap to get tailMap, but its causing concurrency issues. So I decided to use ConcurrentHashMap instead. How do I get tailMap for ConcurrentHashMap? There isn't any API like map.tailMap(key) for ConcurrentHashMap. Thanks