Specifying thread priorities using calls to Thread.setPriority and Thread.getPriority is not portable and may have adverse consequences such as starvation.

Avoid setting thread priorities to control interactions between threads. Using the default thread priority should be sufficient for most applications.

However, if you need to enforce a specific synchronization order, use one of the following alternatives:

In some cases, calls to Thread.sleep may be appropriate to temporarily stop execution (provided that there is no possibility for race conditions), but this is not generally recommended.

  • J. Bloch, Effective Java (second edition), Item 72. Addison-Wesley, 2008.
  • Inform IT: Adding Multithreading Capability to Your Java Applications.