-- AntonioValletta - 15 Nov 2001Realizzare la versione "Mediator" del tipo di dato Monitor utilizzando un monitor di tipo "Gladiator". class Mediator { /* Implements Hoare-like Delay and Continue primitives using Java's wait() and notify(), which provide a kind of monitor where the "continuer" has priority over the "continuee" */ boolean urgent = false; int waiting = 0; public synchronized void mDelay () throws InterruptedException { waiting = waiting + 1; while (!urgent) wait(); urgent = false; notifyAll(); } public synchronized void mContinue () throws InterruptedException { if (waiting != 0) { waiting = waiting - 1; while (urgent) wait(); urgent = true; notifyAll(); wait(); } } }
![]() |
![]() |
Questo sito usa cookies, usandolo ne accettate la presenza. (CookiePolicy)
Torna al Dipartimento di Informatica ![]() |
|
![]() |
![]() |