<pre> <verbatim> Realizzare 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(); } } } </pre> </verbatim> -- Users.AntonioValletta - 15 Nov 2001 <br>
This topic: Sistemioperativi1
>
SoluzioneMediator9Febbraio2000
Topic revision: r1 - 2001-11-15 - AntonioValletta
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback