Basic HTML version of Foils prepared 18 May 97

Foil 7 Synchronized Method and Blocks

From Java Tutorial - Spring 1997 Part 4: Multithreading, useful Java classes, I/O, Networking, and the future Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


1 Synchronized methods and blocks are implemented in the applet class by acquiring a lock before running
2 Code will therefore not run at the same time as other code that needs access to the same resource.
3 Each object has one lock associated with it and each class has exactly one lock
4 When invoked, a synchronized method waits until it can acquire the lock for the current instance (i.e., this); a static synchronized method waits to acquire the class lock
5 Lock is released when code is done executing
6 Locks are advisory
7 synchronized blocks specify the object on which to synchronize

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 Thu Jan 8 1998