package Thread;
public class testthread {
public static void main(String[] args) {
asdf t = new asdf();
Thread tt = new Thread(t,"线程1");
// Thread tt2 = new Thread(t,"线程2");
// Thread tt3 = new Thread(t,"线程3");
tt.start();
// tt2.start();
// tt3.start();
}
}
class asdf implements Runnable{
public void run() {
int i = 0;
boolean b = true;
while(b){
if(i==10){
b = false;
}
try {
Thread.sleep(1000);
System.out.println(Thread.currentThread().getName().toString()+i);
i++;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
public class testthread {
public static void main(String[] args) {
asdf t = new asdf();
Thread tt = new Thread(t,"线程1");
// Thread tt2 = new Thread(t,"线程2");
// Thread tt3 = new Thread(t,"线程3");
tt.start();
// tt2.start();
// tt3.start();
}
}
class asdf implements Runnable{
public void run() {
int i = 0;
boolean b = true;
while(b){
if(i==10){
b = false;
}
try {
Thread.sleep(1000);
System.out.println(Thread.currentThread().getName().toString()+i);
i++;
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}