-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreads.java
More file actions
35 lines (28 loc) · 768 Bytes
/
Copy pathThreads.java
File metadata and controls
35 lines (28 loc) · 768 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
class A extends Thread //Extending Thread class to create a Thread of class A
{
public void run() //Overriding the run() method to implement the Thread
{
for(int i=0; i<=100; i++)
{
System.out.println("Hi");
}
}
}
class B extends Thread //Extending Thread class to create a Thread of class B
{
public void run() //Overriding the run() method to implement the Thread
{
for(int i=0; i<=100; i++)
{
System.out.println("Hello");
}
}
}
public class Threads{
public static void main(String[] args){
A obj1=new A();
B obj2=new B();
obj1.start(); //Starting the Thread of class A
obj2.start(); //Starting the Thread of class B
}
}