提交 d28c93bd 编写于 作者: M martin

6730380: java.util.Timer should use AtomicInteger

Reviewed-by: dl, chegar
上级 6ce5ae98
......@@ -25,6 +25,7 @@
package java.util;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
/**
* A facility for threads to schedule tasks for future execution in a
......@@ -116,12 +117,11 @@ public class Timer {
};
/**
* This ID is used to generate thread names. (It could be replaced
* by an AtomicInteger as soon as they become available.)
* This ID is used to generate thread names.
*/
private static int nextSerialNumber = 0;
private static synchronized int serialNumber() {
return nextSerialNumber++;
private static AtomicInteger nextSerialNumber = new AtomicInteger(0);
private static int serialNumber() {
return nextSerialNumber.getAndIncrement();
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册