CSE 132 (Spring 2011)
Quiz 2: Practice Problems

Synchronization and locks
  1. Which objects in Java have a lock associated with them?
  2. How do you obtain an object's lock before running a method on that object?
  3. How is a thread's execution affected by the use of the synchronized attribute in a method declaration?
  4. Write a java program that uses threads and requires the synchronized attribute on some methods for proper program behavior.
  5. What happened in Studio 4 to Philosophers who try to dine without obtaining locks on chopsticks properly?
  6. Describe (prose) how to obtain multiple locks safely.
  7. Write a method that obtains and holds a lock on every non-null object in Object[] things and then calls r.run().

Last modified 21:09:59 CST 18 January 2011 by Ron K. Cytron