public class ExampleOne {
    private static int x = 0;
    private static int y;
    public static void main(String args[]) throws InterruptedException {
	Runnable r1 = new Runnable () {
		public void run() { 
		    x = 1;
		    y = 2;
		}
	    };
	Runnable r2 = new Runnable () {
		public void run() { 
		    y = x;
		}
	    };
	Thread t1 = new Thread(r1);
	Thread t2 = new Thread(r2);
	t1.start();
	t2.start();
	t1.join();
	t2.join();
	System.out.println("x = "+x+"; y = "+y);
    }
}