mirror of
https://github.com/eclipse-aspectj/aspectj.git
synced 2024-08-15 02:13:50 +02:00
52 lines
1.1 KiB
Java
52 lines
1.1 KiB
Java
//package debugger;
|
|
|
|
public class AJDBThreads {
|
|
public static void main(String[] args) {
|
|
new ThreadForker().go();
|
|
}
|
|
public static String currentThread = "none";
|
|
}
|
|
|
|
class ThreadForker {
|
|
public void go() {
|
|
fork(1000);
|
|
fork(500);
|
|
fork(200);
|
|
fork(100);
|
|
}
|
|
|
|
void fork(long sleep) {
|
|
new NamedThread(sleep).start();
|
|
}
|
|
}
|
|
|
|
class NamedThread implements Runnable {
|
|
private long sleep;
|
|
private String name;
|
|
private Thread thread;
|
|
private int num = 0;
|
|
|
|
public NamedThread(long sleep) {
|
|
this.sleep = sleep;
|
|
}
|
|
|
|
public void start() {
|
|
if (thread == null) {
|
|
thread = new Thread(this);
|
|
name = thread.getName();
|
|
thread.start();
|
|
}
|
|
}
|
|
|
|
public void run() {
|
|
while (true) {
|
|
AJDBThreads.currentThread = name;
|
|
System.out.println("\n********** " + AJDBThreads.currentThread + ":" + (num++) + "\n");
|
|
try {
|
|
Thread.sleep(sleep);
|
|
} catch (Exception e) {
|
|
}
|
|
}
|
|
}
|
|
}
|