Process and Threads Demo
Process Demo ok Threads Demo missing interface part
This commit is contained in:
6
ProcessDemo/.classpath
Normal file
6
ProcessDemo/.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
ProcessDemo/.project
Normal file
17
ProcessDemo/.project
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>ProcessDemo</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>
|
||||||
17
ProcessDemo/src/ProcessDemo.java
Normal file
17
ProcessDemo/src/ProcessDemo.java
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ProcessDemo {
|
||||||
|
// You will have to find your own application path for this
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ProcessBuilder builder = new ProcessBuilder("C:\\Program Files\\HeidiSQL\\heidisql.exe");
|
||||||
|
try {
|
||||||
|
Process process = builder.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
System.out.println("Done...");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
6
ThreadsDemo/.classpath
Normal file
6
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
ThreadsDemo/.project
Normal file
17
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>
|
||||||
31
ThreadsDemo/src/ThreadsDemo.java
Normal file
31
ThreadsDemo/src/ThreadsDemo.java
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
12
ThreadsDemo/src/ThreadsExtend.java
Normal file
12
ThreadsDemo/src/ThreadsExtend.java
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user