public static void main(String[] args) {
new Demo().start();
}
public void start() {
Thread A = new Thread(new Runnable() {
public void run() {
while(true) {
System.out.println("A");
try {
Thread.sleep(500);
}
catch(InterruptedException e) {}
}
}
});
Thread B = new Thread(new Runnable() {
public void run() {
while(true) {
System.out.println("B");
try {
Thread.sleep(2000);
}
catch(InterruptedException e) {}
}
}
});
A.start();
B.start();
}
}
//已經編譯運行過了 over ^_^