public class TestThread {
/**
* @param args
*/
public static void main(String[] args) {
int mmm = 1000;
new Thread(new Runnable() {
@Override
public void run() {
int kkk = 15000;
while(kkk>0){
try {
Thread.sleep(1000);
System.out.println(Thread.currentThread().getName());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
kkk -= 1000;
}
}
},"线程-1").start();
new Thread(new MyThread()," 线程-2").start();
while(mmm <3000){
try {
System.out.println("1000-3000"+Thread.currentThread().getName());
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mmm += 1000;
}
while(mmm <6000){
try {
System.out.println("3000-6000"+Thread.currentThread().getName());
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mmm += 1000;
}
while(mmm <9000){
try {
Thread.sleep(1000);
System.out.println("6000-9000"+Thread.currentThread().getName());
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mmm += 1000;
}
}
static class MyThread extends Thread{
@Override
public void run() {
// TODO Auto-generated method stub
super.run();
int kkk = 15000;
while(kkk>0){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
kkk -= 1000;
System.out.println(Thread.currentThread().getName());
}
}
}