问题描述
for (;;){} while (true) {}
AtomicLong类中getAndIncrement方法用的是while,而incrementAndGet方法用的却是for
楼主问的其实是用for和用while来写无限循环的差别?是的话那么答案是行为没差别,只是语法差别而已。
11 👍 / 6 💬
for (;;){} while (true) {}
AtomicLong类中getAndIncrement方法用的是while,而incrementAndGet方法用的却是for
楼主问的其实是用for和用while来写无限循环的差别?是的话那么答案是行为没差别,只是语法差别而已。