-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask.java
More file actions
37 lines (21 loc) · 829 Bytes
/
Copy pathTask.java
File metadata and controls
37 lines (21 loc) · 829 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
package threads;
public class Task implements Runnable {
@Override
public void run() {
// TODO Auto-generated method stub
try{
String name=Thread.currentThread().getName();
System.out.println("Parent Thread running");
Thread.sleep(2000);
boolean b=true;
if(Thread.currentThread().isDaemon())throw new Exception("Deamon Threads cannot have child process");
// each thread can have its own chiqld process threads .
Thread childThread=new Thread(()->{
System.out.println("Child thread of"+name);
});
childThread.start();
}catch(Exception e){
System.out.println("Thread interupted via"+e.getMessage());
}
}
}