public class TestJava {
public static void main(String[] args) {
A a = new A();
for (int i = 0; i < 3; i++) {
new Thread() {
@Override
public void run() {
a.test();
}
};
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(a.getNum());
}
}
class A {
int num = 0;
public void test() {
for (int i = 0; i < 100000; i++) {
num++;
}
}
public int getNum() {
return num;
}
}