Keith Mattix wrote:So if I make the lock and condition static, then I shouldn't have that problem.
It'll be better, there will be synchronization. There will still be a possible problem with the order of operations. Since all the Runnables use the same Condition then you will lose control over what order they get the signal to run in. Whenever you send the signal any one of the other threads waiting on the condition will be awoken, so there is no guarantee that they will go in the order of a -> b-> number. You will need to either use multiple conditions to ensure the correct order, or use an additional conditional to make sure only the intended thread wakes up.
Joined: Mar 30, 2012
It doesn't have to necessarily be in that order. It could be ab1, b1a, etc.