如果在MyThread类(继承Thread)中将变量声明为static,线程实例是不是也能共享资源了?
class MyThread extends Thread{
static private int count = 5;
void run(){
...
}
}
MyThread mt1 = new MyThread();
MyThread mt2 = new MyThread();
MyThread mt3 = new MyThread();
mt1.start();
mt2.start();
mt3.start();