Janki Shah wrote: class Job1 extends Thread { private Integer number = 0; public void run() { for (int i = 1; i < 100000; i++) { number++; } } public Integer getNumber() { return number; } } public class Test2 { public static void main(String[] args) throws InterruptedException { Job1 thread = new Job1(); thread.start(); synchronized (thread) { thread.wait(); System.out.println(thread.getNumber()); // #1 } System.out.println(thread.getNumber()); //#2 } } OUTPUT: 99999 99999 Why at line #1 it prints 99999? shouldn't it wait() forever? Because there is no notify().
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)