Thread synchronization seems to work using a queue -- that the waiting threads will acquire the released lock in first-in, first-out order. Is this behavior reliable?

Terry Laurenzo

Any ordering that you are observing is not mandated by the spec. It is therefore subject to change and should not be relied on (even using a multi-processor machine instead of a single processor one could affect it). I too have observed this "queue-like" behavior of waiting threads on the Win32 Sun VMs, but I cannot speak for the others.

Without knowing what you are trying to accomplish that requires this ordering, I really cannot spell out a solution. There are a number of ways to ensure ordering, varying from simple(and usually inefficient) to complex.