-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThhread.java
More file actions
40 lines (30 loc) · 846 Bytes
/
Thhread.java
File metadata and controls
40 lines (30 loc) · 846 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
// thread class helps in multiprogramming
// multiprograming(multitasking) = running more than one program at one time.
class my extends Thread
{
// we must override the run method now
public void run()
{
int i = 1;
while(true)
{
System.out.println(i+"hello");
i++;
}
}
}
public class Thhread {
public static void main(String arg [])
{
// creating the object of thread class
my t = new my();
t.start(); //call start to stimulate 2 control flows...
// one control flow prints "i+hello"...other prints "i+world"
int i = 1;
while(true)
{
System.out.println(i+"world");
i++ ;
}
}
}