-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit55_Thread.java
More file actions
37 lines (32 loc) · 879 Bytes
/
Unit55_Thread.java
File metadata and controls
37 lines (32 loc) · 879 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package oop;
/**
*
* @author qngnhat
*/
public class Unit55_Thread {
public static void main(String[] args) {
Thread55 thread55 = new Thread55();
Thread thread1 = new Thread(thread55);
Thread thread2 = new Thread(thread55);
thread1.setName("nez");
thread2.setName("kiki");
thread1.start();
thread2.start();
}
}
class Thread55 implements Runnable {
public void run() {
try {
for (int i = 0; i < 50; i++) {
Thread.sleep(1);
System.out.println(Thread.currentThread().getName() + " " + i);
}
} catch (Exception e) {
}
}
}