All pastes #266957 Raw Edit

Something

public java v1 · immutable
·published 2006-12-04 15:03 UTC
rendered paste body
public class lol {    public static void main(String[] args) {        demo2();    }    public static void demo1() {        final Object lock = new Object();        Thread a = new Thread(new Runnable() {            public void run() {                synchronized (lock) {                    try {                        lock.wait();                    } catch (InterruptedException e) {                    }                    System.out.println("A");                }            }        });        Thread b = new Thread(new Runnable() {            public void run() {                synchronized (lock) {                    lock.notify();                    System.out.println("B");                }            }        });        a.start();        b.start();    }public static void demo2() {final Object lock = new Object();Thread a = new Thread(new Runnable() {public void run() {synchronized (lock) {try {lock.notify();} catch(Exception ex) {}}synchronized (lock) {try {lock.wait();} catch (InterruptedException e) {}System.out.println("A");}}});a.start();synchronized (lock) {lock.wait();}synchronized (lock) {lock.notify();System.out.println("B");}}