Except where otherwise noted, this presentation is licensed under the Creative Commons Attribution 4.0 International License. Third party marks and brands are the property of their respective holders.
priorities 1-10, default is 5 See also: Thread.MIN_PRIORITY , Thread.NORMAL_PRIORITY , Thread.MAX_PRIORITY However, priorities are not guaranteed to be taken into account Managed Runtime Systems 3 of 24 https://foivos.zakkak.net
JVM know that we are willing to stop running to allow other threads to run myThread.join() Pause current thread till the completion of myThread (it can also be given a timeout as argument) Managed Runtime Systems 4 of 24 https://foivos.zakkak.net
be given a timeout as argument). Wait implicitly releases any locks owned by current thread and re-acquires them on notification. myObject.notify() Notify one of the waiting threads to resume execution myObject.notifyAll() Notify all the waiting threads Managed Runtime Systems 5 of 24 https://foivos.zakkak.net
hash-based set with no duplicates BlockingQueue : producer-consumer CopyOnWriteArrayList : optimized synchronized list Managed Runtime Systems 13 of 24 https://foivos.zakkak.net
and its subpackages extend these guarantees to higher-level synchronization. In particular: ▪ Actions in a thread prior to placing an object into any concurrent collection happen-before actions subsequent to the access or removal of that element from the collection in another thread ▪ Actions in a thread prior to the submission of a Runnable to an Executor happen-before its execution begins. Similarly for Callables submitted to an ExecutorService ▪ Actions taken by the asynchronous computation represented by a Future happen-before actions subsequent to the retrieval of the result via Future.get() in another thread Managed Runtime Systems 22 of 24 https://foivos.zakkak.net
such as Lock.unlock, Semaphore.release, and CountDownLatch.countDown happen-before actions subsequent to a successful ”acquiring” method such as Lock.lock, Semaphore.acquire, Condition.await, and CountDownLatch.await on the same synchronizer object in another thread ▪ For each pair of threads that successfully exchange objects via an Exchanger, actions prior to the exchange() in each thread happen-before those subsequent to the corresponding exchange() in another thread ▪ Actions prior to calling CyclicBarrier.await and Phaser.awaitAdvance (as well as its variants) happen-before actions performed by the barrier action, and actions performed by the barrier action happen-before actions subsequent to a successful return from the corresponding await in other threads Managed Runtime Systems 23 of 24 https://foivos.zakkak.net