<pre name="code" class="java">public class test {
public static void main(String[] args) {
testThread test = new testThread();
Thread a = new Thread(test,"a");
Thread b = new Thread(test,"b");
Thread c = new Thread(test,"c");
a.start();
b.start();
c.start();
}
}
class testThread extends Thread{
private int count = 5;
synchronized public void run(){
count--;
System.out.println("由"+this.currentThread().getName()+"计算,count="+count);
}
}
public class test {
public static void main(String[] args) {
testThread test = new testThread();
Thread a = new Thread(test,"a");
Thread b = new Thread(test,"b");
Thread c = new Thread(test,"c");
a.start();
b.start();
c.start();
}
}
class testThread extends Thread{
private int count = 5;
public void run(){
count--;
System.out.println("由"+this.currentThread().getName()+"计算,count="+count);
}
}