标题: 关于多线程,我想问 [打印本页] 作者: heheka123 时间: 2014-3-31 15:52 标题: 关于多线程,我想问 看书看到多线程的时候,书上讲到了线程同步的内容,然后是举了个例子,代码如下
class My implements Runnable{
private int count =0;
public void run(){
test();
}
private void test(){
for(int i=0;i<10;i++){
count++;
Thread.yield();
count--;
System.out.println(count);
}
}
}
public class Test {
public static void main(String args[]) throws InterruptedException{
My t=new My();
Thread t1=new Thread(t);
Thread t2=new Thread(t);