johnson666 最近的时间轴更新
johnson666

johnson666

V2EX 第 291227 号会员,加入于 2018-02-10 13:46:49 +08:00
johnson666 最近回复了
2021-01-25 16:05:58 +08:00
回复了 Cbdy 创建的主题 Java 求一个 Java 面试题的最佳实践
原子变量

public class Test {
public static void main(String[] args) {
AtomicInteger at = new AtomicInteger();
for (int i = 0; i < 3; i++) {
MyThread t = new MyThread(at, i);
t.start();
}
}
}

class MyThread extends Thread {
private AtomicInteger at;
private int index;

public MyThread(AtomicInteger at, int index) {
this.at = at;
this.index = index;
}

@Override
public void run() {
while(true) {
if(at.get() % 3 == index) {
System.out.print((char)('a' + index));
at.incrementAndGet();
}
}
}
}
2018-02-26 10:20:52 +08:00
回复了 yuzenan888 创建的主题 Linux 麻烦推荐一个树莓派能用的 4G 网卡(卡托)
真不懂为啥这么用
2018-02-15 22:20:35 +08:00
回复了 isCyan 创建的主题 支付宝 大家集五福拿了多少钱?
1.98
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5289 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 08:07 · PVG 16:07 · LAX 01:07 · JFK 04:07
Developed with CodeLauncher
♥ Do have faith in what you're doing.