Hi
Your method is correct but unfortunately can fail by usage. This a classic problem with the
test method in multi thread environment - consider the example :
and the usage is :
We play with two threads A and B. Thread A checks if the test() condition is true and it fid it true so Thread A moves from line if (test()) to doTrue(). At
this point the thread scheduler suspend Thread A and runs the Thread B, this thread change the variable condition checked with test() method. After this t
hread A comes back and execute doTrue(); even if the test() method return false.
Regards,
Mihai
SCJP, SCJD, SCWCD, OCPJBCD