Basic HTML version of Foils prepared Sept 21 1998

Foil 11 Synchronization is Implemented by Monitors

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken


1 An object that can block threads and notify them when it is available is called a monitor. A monitor is associated with an instance of the class; it has a lock and a queue.
2 If a class has one or more synchronized methods, each object (instance) of the class has a monitor. The queue holds all threads waiting to execute a synchronized method.
  • A thread enters the queue by calling wait() inside the method or when another thread is already executing the method.
  • When a synchronized method returns, or when a method calls wait(), another thread may access the object.
  • As always, the scheduler chooses the highest-priority thread among those in the queue.
  • If a thread is put into the queue by calling wait(), it can't be scheduled for execution until some other thread calls notify().

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998