Skip to content

Commit cb8e585

Browse files
committed
fix compilation issues yet again
1 parent 6692a27 commit cb8e585

12 files changed

Lines changed: 273 additions & 0 deletions

File tree

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager">
4+
<output url="file://$MODULE_DIR$/../out/production/JavaMultithreading" />
5+
<output-test url="file://$MODULE_DIR$/../out/test/JavaMultithreading" />
6+
<exclude-output />
7+
<content url="file://$MODULE_DIR$/../JavaMultithreading">
8+
<sourceFolder url="file://$MODULE_DIR$/../JavaMultithreading/src" isTestSource="false" />
9+
</content>
10+
<orderEntry type="jdk" jdkName="16" jdkType="JavaSDK" />
11+
<orderEntry type="sourceFolder" forTests="false" />
12+
</component>
13+
</module>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.practice.nishith;
2+
3+
public class Demo {
4+
5+
static Thread myThreadOne;
6+
static Thread myThreadTwo;
7+
8+
public static void main(String[] args) throws InterruptedException {
9+
// Runner runnerOne = new Runner();
10+
// runnerOne.start();
11+
// Runner runnerTwo = new Runner();
12+
// runnerTwo.start();
13+
// Runner runnerThree = new Runner();
14+
// runnerThree.start();
15+
16+
17+
// Thread runnerOne = new Thread(new RunnableInterfaceImplementation());
18+
// runnerOne.start();
19+
// Thread runnerTwo = new Thread(new RunnableInterfaceImplementation());
20+
// runnerTwo.start();
21+
// Thread runnerThree = new Thread(new RunnableInterfaceImplementation());
22+
// runnerThree.start();
23+
24+
myThreadOne = new Thread(new MyThread());
25+
System.out.println("State of the thread one after creating the thread : "+myThreadOne.getState());
26+
myThreadOne.start();
27+
System.out.println("State of the thread one after calling the start method : "+myThreadOne.getState());
28+
29+
myThreadTwo = new Thread(new MyThread());
30+
System.out.println("State of the thread two after creating the thread : "+myThreadTwo.getState());
31+
myThreadTwo.start();
32+
System.out.println("State of the thread two after calling the start method : "+myThreadTwo.getState());
33+
34+
myThreadOne.sleep(200);
35+
36+
myThreadTwo.join();
37+
38+
39+
}
40+
41+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.practice.nishith;
2+
3+
public class MyThread implements Runnable{
4+
5+
@Override
6+
public void run() {
7+
//System.out.println("MyThread Using Runnable Interface:" + i);
8+
try {
9+
Thread.sleep(1000);
10+
} catch (InterruptedException e) {
11+
e.printStackTrace();
12+
}
13+
System.out.println("State of the threadOne while it called join method on threadTwo "+Demo.myThreadOne.getState());
14+
15+
try {
16+
Thread.sleep(200);
17+
} catch (InterruptedException e) {
18+
// TODO Auto-generated catch block
19+
e.printStackTrace();
20+
}
21+
22+
}
23+
24+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.practice.nishith;
2+
3+
public class RunnableInterfaceImplementation implements Runnable {
4+
5+
@Override
6+
public void run() {
7+
for (int i=0;i<5;i++) {
8+
System.out.println("Hello Using Runnable Interface:" + i);
9+
try {
10+
Thread.sleep(1000);
11+
} catch (InterruptedException e) {
12+
e.printStackTrace();
13+
}
14+
}
15+
16+
17+
}
18+
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.practice.nishith;
2+
3+
public class Runner extends Thread {
4+
5+
@Override
6+
public void run() {
7+
for (int i=0;i<5;i++) {
8+
System.out.println("Hello Using Thread Extension:" + i);
9+
try {
10+
Thread.sleep(1000);
11+
} catch (InterruptedException e) {
12+
// TODO Auto-generated catch block
13+
e.printStackTrace();
14+
}
15+
}
16+
17+
}
18+
19+
20+
21+
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)