Semaphore initialisation

Semaphore initialisation

When used for signalling, semaphores are initialised to 0.

// Create Semaphore, initialise to 0

Semaphore S = new Semaphore(0);

// Create Threads

Thread A = new Thread(new Signaller(s));

Thread B = new Thread(new Waiter(s));

//Start Threads

A.start();

B.start();

Previous slide Next slide Back to the first slide View Graphic Version