[concurrency-interest] Hung progress in ThreadPoolExecutor ExecutorCompletionService when slave threads killed.

Dr Heinz M. Kabutz heinz at javaspecialists.eu
Mon May 14 01:10:44 EDT 2012


When you stop() a thread that has called wait(), it first reacquires
the monitor before bailing out.  The monitor is then automatically
unlocked again when you leave the scope.

However, Condition.await() does *not* reacquire the lock when you
stop() the thread.  When unlock() is then called on Lock as you exit
the scope, an IllegalMonitorStateException is then thrown.  I would
love to know if that is deliberate or a coding bug?

Anyway, my bet is that this is the culprit.  You can also see the
await() method in the stack trace.

Heinz

On 14/05/2012, Zhong Yu <zhong.j.yu at gmail.com> wrote:
> If an exception can occur any where any time, it is impossible to
> write code that can survive it and maintain invariants.
>
>     lock
>         x++;
>         y++;
>     unlock
>
> If we have to worry that some exception may be thrown between x++ and
> y++, we cannot write any program at all.
>
> ThreadDeath is exactly such an exception.
>
> Others include OutOfMemoryError and StackOverflowError - they are more
> predictable, but still, we cannot afford to worry about them on every
> `new` and every method call.
>
> Zhong Yu
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>


-- 
Dr Heinz M. Kabutz (PhD CompSci)
Author of "The Java(tm) Specialists' Newsletter"
Sun Java Champion
IEEE Certified Software Development Professional
http://www.javaspecialists.eu
Tel: +30 69 75 595 262
Skype: kabutz


More information about the Concurrency-interest mailing list