uses "console", "thread", "sys"; class WaitThread extends Thread { atomic static number count = 0; number id; number hits; static object ev; function WaitThread( ) { super(); if(!WaitThread.ev) WaitThread.ev = new Event(); self.hits = 0; self.id = ++WaitThread.count; } static function GetEvent() { return WaitThread.ev; } function run() { Console.println("running..."); while( self.hits < 2 ) { Console.println( "Thread ${.id}: is waiting" ); WaitThread.ev.wait(); Console.println( "Thread ${.id}: got signal" ); self.hits++; } Console.println( "Leaving Thread " + self.id ); } } object t1 = new WaitThread(); object t2 = new WaitThread(); object t3 = new WaitThread(); object ev = WaitThread.GetEvent(); number counter = 0; Console.println("starting threads..."); t1.start(true); t2.start(true); t3.start(true); while(true) { counter++; Sys.usleep( 1000000 ); Console.println( "Main Loop [$counter seconds passed]" ); Console.println( "Sending Signal." ); ev.signal(); if( counter == 10 ) { Console.println( "Stopping Script" ); break; } }