import java.util.Vector; public class LockRecords { static final int N = 3; static Vector v; static class MyObject { public int id; public int counter; protected void finalize() throws Throwable { System.out.println("\tObject #" + id + " gets finalized"); throw new Exception("Object #" + id + " is nasty!"); } }; static class MyThread extends Thread { public String name; public synchronized void run() { System.out.println("\t" + name + ": Starting ..."); try { for (int i=0; i 0) { this.wait(10); } } } catch (Exception e) { e.printStackTrace(); } System.out.println("\t" + name + ": finished."); } }; public synchronized void test() { System.out.println("Creating Objects ..."); v = new Vector(); for (int i=0; i