public class SemAlt { static Semaphore c = new Semaphore(1); static Semaphore r = new Semaphore(0); static class Caller extends Thread { public void run () { int i; for (i = 0; i < 10; i++) { c.P(); System.out.println("Call"); r.V(); } } } static class Returner extends Thread { public void run () { int i; for (i = 0; i < 10; i++) { r.P(); System.out.println("Return"); c.V(); } } } public static void main(String[] args) { Caller c = new Caller(); Returner r = new Returner(); c.start(); r.start(); } }