-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJoin.java
More file actions
31 lines (24 loc) · 722 Bytes
/
Join.java
File metadata and controls
31 lines (24 loc) · 722 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
// Java program to illustrate join() method in Java
import java.lang.*;
public class JoinDemo implements Runnable
{
public void run()
{
Thread t = Thread.currentThread();
System.out.println("Current thread: "+ t.getName());
// checks if current thread is alive
System.out.println("Is Alive? "+ t.isAlive());
}
public static void main(String args[]) throws Exception
{
Thread t = new Thread(new JoinDemo());
t.start();
// Waits for 1000ms this thread to die.
t.join(1000);
System.out.println("\nJoining after 1000"+" mili seconds: \n");
System.out.println("Current thread: " +
t.getName());
// Checks if this thread is alive
System.out.println("Is alive? " + t.isAlive());
}
}