Not sure if that's the problem , but you may want to declare isRunning as volatile - indicating its value can be altered in different threads.
From what I remember - you shouldn't rely on thread priorities for doing anything meaningful. Their implementation is (or used to be) very uneven and sometimes changed between JVM versions, so it is better not to rely on them. Maybe Henry will chime in on this, he'd know for sure.
Alexandru Gifei wrote:Declaring the flags as volatile did the job. Thanks!
True. I guess when the count is not volatile, the 2 threads tries to do code optimization by reading/writing the variable to cache/master location. Hence the 2 thread enter race condition and will not terminate.
SCJP 1.4, SCWCD1.4, OCA(1Z0-007)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com