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.
19
votes
8answers
23k views
Is there a Mutex in Java?
Is there a Mutex object in java or a way to create one?
I am asking because a Semaphore object initialized with 1 permit does not help me.
Think of this case:
try {
semaphore.acquire();
//do ...
15
votes
4answers
18k views
java.util.ConcurrentModificationException in Non Multithreaded Program
Hey SO Guru's im having one heck of a job with this code
public void kill(double GrowthRate, int Death)
{
int before = population.size();
for (PopulationMember p : population)
{
...
6
votes
6answers
2k views
Java ThreadPool usage
I'm trying to write a multithreaded web crawler.
My main entry class has the following code:
ExecutorService exec = Executors.newFixedThreadPool(numberOfCrawlers);
while(true){
URL url = ...
9
votes
1answer
671 views
Why aren't Java.util.concurrent.TimeUnit types greater than SECONDS available in Android?
I miss MINUTES, HOURS, DAYS, which exist in documentaion since API level 1 (I use 7th or 2.1 version for the application).
I have read this question, where this miss was also pointed out (though, it ...
4
votes
5answers
1k views
java.util.ConcurrentModificationException On MapView
fellas
I am facing very strange issue from many days. I am trying to update overlay frequently. So sometime I am getting "java.util.ConcurrentModificationException" when I touch on map or sometime ...
6
votes
5answers
170 views
Can synchronized blocks be faster than Atomics?
Suppose two following counter implementations:
class Counter {
private final AtomicInteger atomic = new AtomicInteger(0);
private int i = 0;
public void incrementAtomic() {
...
14
votes
3answers
12k views
Thread safe Hash Map?
I am writing an application which will return a HashMap to user. User will get reference to this MAP.
On the backend, I will be running some threads which will update the Map.
What I have done so ...
6
votes
2answers
2k views
Difference between Executor and ExecutorCompletionservice in java
As the question title itself says what is the difference between Executors and ExecutorCompletionService classes in java?
I am new to the Threading,so if any one can explain with a piece of code, ...
5
votes
2answers
2k views
Single threading a task without queuing further requests
I have a requirement for a task to be executed asynchronously while discarding any further requests until the task is finished.
Synchronizing the method just queues up the tasks and doesn't skip. I ...
2
votes
2answers
1k views
How does java.util.concurrent.Executor work?
How does java.util.concurrent.Executor create the "real" thread?
Suppose I am implementing Executor or using any executor service (like ThreadPoolExecutor). How does JVM internally work?
5
votes
5answers
303 views
Is ConcurrentHashMap totally safe?
this is a passage from JavaDoc regarding ConcurrentHashMap. It says retrieval operations generally do not block, so may overlap with update operations. Does this mean the get() method is not thread ...
3
votes
2answers
627 views
Directory Scanner in Java
Scan a set of directories continuously for a set of file name filters.
For each file name filter arrived, process the file and repeat the steps for all
What can be the recommended design for this in ...
11
votes
5answers
16k views
How to give name to a callable Thread?
I am executing a Callable Object using ExecutorService thread pool. I want to give a name to this thread.
To be more specific, in older version I did this -
Thread thread = new Thread(runnable ...
3
votes
2answers
127 views
List<Runnable> returned from shutdownNow() can not be converted to submitted Runnable
Below is the source code of the class.
I wanted to verify how does shutdownNow() works for not submitted task. Problem I am getting in below code is shutdownNow() return List<FutureTask> and ...
2
votes
2answers
160 views
What operations depend on the capacity of a LinkedHashMap ? Is there any concurrent version available?
I am using a ConcurrentHashMap as my datastructure because mutiple threads will be reading and writing to it concurrently. But I am finding that the client code will also need to iterate over it ...