Process and Threads Demo

Process Demo ok
Threads Demo missing interface part
This commit is contained in:
Karsten Jeppesen
2021-02-15 07:37:50 +01:00
parent 71d5dfaf15
commit 1a88f622ad
7 changed files with 106 additions and 0 deletions

6
ThreadsDemo/.classpath Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
ThreadsDemo/.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ThreadsDemo</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,31 @@
public class ThreadsDemo {
public static void main(String[] args) {
ThreadsExtend myThreadA = new ThreadsExtend("A");
ThreadsExtend myThreadB = new ThreadsExtend("B");
ThreadsExtend myThreadC = new ThreadsExtend("C");
myThreadA.start();
myThreadB.start();
myThreadC.start();
try {
myThreadA.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
myThreadB.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
myThreadC.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,12 @@
public class ThreadsExtend extends Thread {
private String MyString;
public ThreadsExtend( String InitString) {
MyString = InitString;
}
public void run() {
System.out.println(MyString + " running");
}
}