-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathLab10q7.java
More file actions
49 lines (49 loc) · 900 Bytes
/
Lab10q7.java
File metadata and controls
49 lines (49 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class MyThread extends Thread
{
String name;
MyThread(String tname)
{
name=tname;
start();
}
public void run()
{
try
{
for(int i=0;i<10;i++)
{
System.out.println(name+" : "+i);
Thread.sleep(100);
}
}
catch(InterruptedException e)
{
System.out.println(name+" interrupted.");
}
System.out.println(name+" exiting ");
}
}
class Lab10q7
{
public static void main(String args[])
{
MyThread t1=new MyThread("THREAD");
try
{
Thread.sleep(500);
t1.suspend();
System.out.println("THREAD SUSPENDED");
Thread.sleep(500);
t1.resume();
System.out.println("THREAD RESUMED");
Thread.sleep(500);
t1.stop();
System.out.println("THREAD STOPPED");
}
catch(InterruptedException e)
{
System.out.println("MAIN THREAD INTERRUPTED.");
}
System.out.println("MAIN THREAD EXITING");
}
}