aboutsummaryrefslogtreecommitdiff
path: root/sem5/oop/m5/opg2/src/PrintThread.java
blob: 50b8425826d30196f7b1a88e301f87bd77daf02f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class PrintThread extends Thread {
	private int sleepTime;
   
	public PrintThread(String id )
		{
		super(id);
	   	sleepTime = (int) ( Math.random() * 5000 );
	   	System.out.println( "Name: " + getName() +" Sleep: " + sleepTime );
	  }
	  
	public void run()
		{
			try {
				sleep( sleepTime );
				}
			catch ( InterruptedException exception ) {}
		System.out.println( "Thread " + getName() );
   }

}