first commit
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import java.util.*;
|
||||
|
||||
class ThreadExample extends Thread {
|
||||
String s;
|
||||
Random r;
|
||||
public ThreadExample(String s) {
|
||||
this.s = s;
|
||||
this.r = new Random();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
for(int i=0; i<5; i++) {
|
||||
System.out.println(s);
|
||||
try {
|
||||
this.sleep(r.nextInt(100));
|
||||
} catch (InterruptedException e)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
new ThreadExample("String One").start();
|
||||
new ThreadExample("String Two").start();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user