当前位置: 代码迷 >> J2EE >> 线程同步的解决思路
  详细解决方案

线程同步的解决思路

热度:62   发布时间:2016-04-21 22:57:30.0
线程同步的
package util;

public class B {
static class C {
static int i = 1;
public C(){
Thread thread1 = new Thread("a") {
public void run() {
for (;;) {
C.run();
}
}
};
Thread thread2 = new Thread("c") {
public void run() {
for (;;) {
C.run();
}
}
};
thread1.start();
thread2.start();
}
public synchronized static void run() {
{
System.out.println("i = " + i+Thread.currentThread().getName());
i++;
}
}
}
public static void main(String[] args) throws Exception {
new C();
}
}
多线程 java

------解决方案--------------------
你贴个代码出来.谁干什么啊?同步???
------解决方案--------------------
LZ想表达什么意思呢?
------解决方案--------------------
哈哈,楼主两位不要这样吗,会吓到楼主得
  相关解决方案