26 lines
542 B
Java
26 lines
542 B
Java
package org.gcube.application.framework.core.session;
|
|
|
|
import java.util.concurrent.Semaphore;
|
|
|
|
class Notifier {
|
|
|
|
Semaphore sem;
|
|
|
|
Notifier() {
|
|
sem = new Semaphore(0, true);
|
|
}
|
|
|
|
|
|
public void waitNotification() throws InterruptedException
|
|
{
|
|
sem.acquire();
|
|
System.out.println("\n\njust woke up!!!\n\n");
|
|
}
|
|
|
|
public void notifyAllWaiting() throws InterruptedException
|
|
{
|
|
System.out.println("Sending wake up signal to " + sem.getQueueLength() + " receivers...");
|
|
sem.release(sem.getQueueLength());
|
|
}
|
|
}
|