public class ThreadUse2 implements Runnable {
public int id = 1;
public static void main(String[] args) {
ThreadUse2 tr = new ThreadUse2();
Thread t1 = new Thread(tr);
Thread t2 = new Thread(tr);
Thread t3 = new Thread(tr);
t1.start();
t2.start();
t3.start();
}
public void run() {
while (id <= 20) {
System.out.print(id + " ");
Thread.yield();
id++;
}
}
}