All pastes #584018 Raw Edit

Miscellany

public java v1 · immutable
·published 2007-06-22 16:16 UTC
rendered paste body
package dlcspm4.virtualPlgr;public class Test1{	public Test1()	{		Test2 mytest = new Test2();		mytest.begin();				try		{			System.out.println("Sleeping");			Thread.sleep(3000);			System.out.println("/Sleeping");			mytest.begin();		}		catch(Exception e)		{			;		}	}	public static void main(String[] args)	{		Test1 test = new Test1();	}}package dlcspm4.virtualPlgr;public class Test2 extends Thread{	private boolean stopper = false;	public void run()	{		System.out.println("run() entered");		int i = 0;		while(stopper)		{			System.out.print(i + " ");			++i;			if(i > 9)			{				this.stopper = false;				System.out.println();			}		}					System.out.println("run() is about to exit");	}		public void begin()		{			this.stopper = true;			// This begin() was called previous, isAlive()			// is never again false even after run() exits.			if(!this.isAlive())			{				this.start();			}			else			{				System.out.println("Can't execute again, thread still alive!");			}		}		public void end()		{			this.stopper = false;		}}