Tony Docherty wrote:Either of them.
AFAIK at the end of a synchronized block all threads waiting on that block are woken and (assuming they are all the same priority) whichever one acquires the monitor gets to execute the code.
Agreed. And they don't even have to be at the same priority. Thread priority behaviors are handle by the underlying threading system (for most JVM implementations), and there are a few reasons why the OS threading system may choose to run a lower priority thread over a higher priority thread.
Henry