Separating into Tech and SysDev
This commit is contained in:
6
Technology/ThreadsDemo/.classpath
Normal file
6
Technology/ThreadsDemo/.classpath
Normal 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
Technology/ThreadsDemo/.project
Normal file
17
Technology/ThreadsDemo/.project
Normal 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>
|
||||
26
Technology/ThreadsDemo/src/Level1Interface.java
Normal file
26
Technology/ThreadsDemo/src/Level1Interface.java
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Demo of thread starting a thread
|
||||
//
|
||||
|
||||
public class Level1Interface implements Runnable {
|
||||
|
||||
private String MyString;
|
||||
|
||||
public Level1Interface(String InitString) {
|
||||
MyString = InitString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(MyString + " Interface");
|
||||
ThreadsExtend myThreadA = new ThreadsExtend( MyString + "A" );
|
||||
myThreadA.start();
|
||||
try {
|
||||
myThreadA.join();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(MyString + " Interface...Done");
|
||||
}
|
||||
}
|
||||
34
Technology/ThreadsDemo/src/ThreadsDemo.java
Normal file
34
Technology/ThreadsDemo/src/ThreadsDemo.java
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
public class ThreadsDemo {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ThreadsExtend myThreadA = new ThreadsExtend("A");
|
||||
ThreadsExtend myThreadB = new ThreadsExtend("B");
|
||||
ThreadsExtend myThreadC = new ThreadsExtend("C");
|
||||
Runnable myRunnableD = new ThreadsInterface("D");
|
||||
Runnable myRunnableE = new ThreadsInterface("E");
|
||||
Runnable myRunnableF = new Level1Interface("F");
|
||||
myThreadA.start();
|
||||
myThreadB.start();
|
||||
myThreadC.start();
|
||||
Thread myThreadD = new Thread( myRunnableD );
|
||||
myThreadD.start();
|
||||
Thread myThreadE = new Thread( myRunnableE );
|
||||
myThreadE.start();
|
||||
Thread myThreadF = new Thread( myRunnableF );
|
||||
myThreadF.start();
|
||||
|
||||
try {
|
||||
myThreadA.join();
|
||||
myThreadB.join();
|
||||
myThreadC.join();
|
||||
myThreadD.join();
|
||||
myThreadE.join();
|
||||
myThreadF.join();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Main Done...");
|
||||
}
|
||||
}
|
||||
20
Technology/ThreadsDemo/src/ThreadsExtend.java
Normal file
20
Technology/ThreadsDemo/src/ThreadsExtend.java
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
public class ThreadsExtend extends Thread {
|
||||
private String MyString;
|
||||
|
||||
public ThreadsExtend ( String InitString ) {
|
||||
MyString = InitString;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(MyString + " running");
|
||||
}
|
||||
|
||||
}
|
||||
15
Technology/ThreadsDemo/src/ThreadsInterface.java
Normal file
15
Technology/ThreadsDemo/src/ThreadsInterface.java
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
public class ThreadsInterface implements Runnable {
|
||||
|
||||
private String MyString;
|
||||
|
||||
public ThreadsInterface(String InitString) {
|
||||
MyString = InitString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println(MyString + " Interface");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user