For some reason this code freezes at the output of:
1
1
Been really struggling to get wait/notify to work. Can someone please tell where I can get some good examples. I have the K & B book, but are there any other good examples?
public class RunningMan implements Runnable{
public RunningMan() {
}
public synchronized void run() {
for (int x = 1; x < 77; x++){
notify();
System.out.println(x);
try {
wait();
}catch (Exception e){
};
}
}
public static void main(
String[] args) {
Thread t1 = new Thread(new RunningMan());
Thread t2 = new Thread(new RunningMan());
t1.start();
t2.start();
}
}