关于Java支持哪些无符号数据类型,我有点困惑?
我读过这篇文章,但我不明白其非常复杂的解释(至少对我而言).
以下是OCJP考试的代码
class Test implements Runnable{
synchronized void hit(long n) {
for(int i = 1; i < 3; i++)
System.out.print(n + "-" + i + " ");
}
public static void main(String... args) throws Exception{
new Thread(new Test()).start();
new Thread(new Test()).start();
}
@Override
public void run() {
hit(Thread.currentThread().getId());
}
}
Run Code Online (Sandbox Code Playgroud)
答案:8-1 7-1 7-2 8-2和
8-1 8-2 7-1 7-2
如何预测这个输出?