lpr-b:ilthread
<code java> package TestIngresso;
public class IlThread extends Thread {
AlternatingProtocol ap = null; int order = 0;
public IlThread(AlternatingProtocol ap, int order) { this.ap = ap; this.order = order; }
public void run() { if(order == 0) { ap.P(); } while(true) { System.out.println(this.getName() + " sbloccato"); int secs = ((int) (Math.random() * 10.0)); while(secs > 0) { try { Thread.sleep(1000); } catch(InterruptedException e) { e.printStackTrace(); } System.out.println(this.getName() +" "+ secs--); } ap.V(); System.out.println(this.getName()+ " in attesa ..."); ap.P(); } }
} <code>
lpr-b/ilthread.txt · Ultima modifica: 28/09/2007 alle 09:09 (18 anni fa) da Marco Danelutto