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

Java Concurrent Multi-Threaded Algorithm in a Web App - Slower Than Expected

I ran into an issue in my Java web application today and need a 2nd (and 3rd, and 4th) set of eyeballs to see where I've messed up and how best to fix it. The web app collects bids each round of an auction, and then fills in missing bids for bidders…
bluedevil2k
  • 9,366
  • 8
  • 43
  • 57
0
votes
2 answers

how to switch to a new activity only by either pressing abutton or waiting for a specific time

From an activity,I want to switch to another activity either by pressing a button or by waiting for some time (For example - 5 seconds). In the code below,if the user pressed the button within less than the specified timing (e.g: 5 seconds), he will…
user3558352
0
votes
1 answer

Java ExecuterCompletionService take.get() from different thread

In Java I have a web service that starts some long running processes on different threads so that I can return a http status without the connection timing out. My question involves creating a single long running thread that will simply run the…
twreid
  • 1,453
  • 2
  • 22
  • 42
0
votes
1 answer

I want to send Run time Notification through E-mail in my designed web application by using Executors Thread Pool

It may be a silly question but i am newbie on this, I am creating a web application where notifications are send by Email. For this i am planning to use Executor Service. I am bit confused in Executor Service , should i use (ExecutorService es…
vaib
  • 319
  • 4
  • 27
0
votes
1 answer

Java concurrent tasks implementation

My problem is this: I can have a maximum of three concurrent tasks running. These tasks can process 1 to 100 jobs simultaneously. I have many threads constantly submitting single jobs, and I want to respond to them as fast as possible. The time…
jimjim
  • 420
  • 3
  • 10
0
votes
1 answer

Boolean Semaphore in Java

I have a simple "play/pause" flag. Imagine a doer thread: private final Thread backgroundDoer = new Thread(() -> { while(true) { doOperation(); playFlag.await(); } }) So keep doing an operation unless the flag…
CarrKnight
  • 2,768
  • 2
  • 23
  • 25
0
votes
3 answers

Understanding the code execution path for given code

I am new to Java, Can anyone explain me which method invokes the call method in below given code , also help me to understand the code execution path for give code: import java.util.ArrayList; import java.util.Date; import java.util.List; import…
0
votes
3 answers

Downloader.downloadFile(urls) - What is this line doing, and Generics in Java

I am reading up on AsyncTask from this tutorial. And the following piece of code is given as an example: private class DownloadFilesTask extends AsyncTask { protected Long doInBackground(URL... urls) { int count =…
Solace
  • 8,612
  • 22
  • 95
  • 183
0
votes
2 answers

Java ThreadPool reporting

I have a worker threadpool set up that executes a bit of work which I want to log in a central place. To be more precise, I've extended the Thread class into a worker class, which checks the status of a concurrent queue. If it's empty, then it…
CodeOcelot
  • 3,403
  • 3
  • 22
  • 23
0
votes
2 answers

bounded ScheduledThreadPoolExecutor`s submit method don`t call ThreadFactory after release of a full queue

let corePoolSize = 4, after four calls to the submit(or scheduleAtFixedRate and etc) methods, query filled and the method getActiveCount() returns the correct value 4, after the cancellation working task through future.cancel(true) value decreases…
0
votes
2 answers

Synchronization on ConcurrentHashMap

In my application I am using a ConcurrentHashMap and I need this type of "custom put-if-absent" method to be executed atomically. public boolean putIfSameMappingNotExistingAlready(String key, String newValue) { String value; synchronized…
0
votes
2 answers

Getting java.util.ConcurentModificationError in collision detecton

Here I am getting java.util.ConcurentModificationError in the line for(Candy c2 : candylist) {. Can any one tell me whats wrong? I am trying to check the collision detection of several images managed in two linked lists say 1st list of balloon 2nd…
Shubhankar
  • 95
  • 1
  • 14
0
votes
1 answer

Real world example of drainTo method behavior

I was going through the javadocs and source code for drainTo method present in BlockingQueue interface and LinkedBlockingQueue implementation of the same. My understanding of this method after looking at the source (JDK7), is that the calling…
userx
  • 3,713
  • 5
  • 32
  • 38
0
votes
1 answer

Condition Interface in Java

I'm trying to write some classes that implements the java.util.concurrent.locks.Lock interface, one of the methods that should be overridden is condition that returns a condition associated with the lock. Is there an implementation for the…
Dor Mesica
  • 507
  • 1
  • 7
  • 23
0
votes
2 answers

java.util.concurrent.ExecutionException: java.util.ConcurrentModificationException

I am getting a concurrent modification exception when executing the following code: mymap is a global variable and is a HashMap Callable task = new Callable() { @Override public String call() { …
chapstick
  • 713
  • 6
  • 16
  • 25