-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathJava Thread Methods1
44 lines (38 loc) · 941 Bytes
/
Java Thread Methods1
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
package com.company;
class MyNewThr1 extends Thread{
public void run(){
int i = 0;
while(true){
// System.out.println("I am a thread");
System.out.println("Thank you: ");
try {
Thread.sleep(455);
} catch (InterruptedException e) {
e.printStackTrace();
}
i++;
}
}
}
class MyNewThr2 extends Thread{
public void run(){
while(true){
// System.out.println("I am a thread");
System.out.println("My Thank you: ");
}
}
}
public class cwh_75_thread_methods {
public static void main(String[] args){
MyNewThr1 t1 = new MyNewThr1();
MyNewThr2 t2 = new MyNewThr2();
t1.start();
// try{
// t1.join();
// }
// catch(Exception e){
// System.out.println(e);
// }
t2.start();
}
}