I just glanced through your code, didn't compile it nor run.
I am rather unfamiliar with new Java concurrency gadgets details.
Your locking class:
Why it should be a singleton?
Why it's factory is not concurrency aware?
>>Why it should be a singleton?
Just to make sure all threads calls the same "waitForCondition" method
and references the same lock.
>> Why it's factory is not concurrency aware?
My idea was that since it is actually only of interest the first time
someone accesses (and therefor creates a new object) it, I didn't
regarded it important.
But it actually turned out that this was the problem! If two threads
get different instances then my code won't work (see the previous
comment).
So thanks for the comment. Problem solved!
Stefan Schulz - 07 Dec 2005 12:01 GMT
>>>Why it should be a singleton?
> Just to make sure all threads calls the same "waitForCondition" method
[quoted text clipped - 8 lines]
> comment).
> So thanks for the comment. Problem solved!
This is why i tend to initialize singletons statically. This way, this
nasty bit of unpleasantness can not happen, and you need not synchronize
in the getInstance method.

Signature
You can't run away forever,
But there's nothing wrong with getting a good head start.
--- Jim Steinman, "Rock and Roll Dreams Come Through"
Fiz - 07 Dec 2005 14:12 GMT
I guess your main thread calls the executor.shutdown() before even the
callable tasks added to the executorservice completes. Try using a
barrier (java.util.concurrent.CyclicBarrier) to wait for all the
submitted tasks to complete before calling the shutdown.
Ake L - 11 Dec 2005 09:42 GMT
> I guess your main thread calls the executor.shutdown() before even the
> callable tasks added to the executorservice completes. Try using a
> barrier (java.util.concurrent.CyclicBarrier) to wait for all the
> submitted tasks to complete before calling the shutdown.
I thought that was what the CompletionService.take() does?
>From the API docs:
"Retrieves and removes the Future representing the next completed task,
waiting if none are yet present."
Ake L - 11 Dec 2005 09:09 GMT
Very good point, I never thought of that.
Ake L - 11 Dec 2005 09:15 GMT
I meant Stefan's comment about initializing singletons statically.