From d28c93bd9573751f4c7aa045f433e345cbc20471 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 1 Aug 2008 00:38:02 -0700 Subject: [PATCH] 6730380: java.util.Timer should use AtomicInteger Reviewed-by: dl, chegar --- src/share/classes/java/util/Timer.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/share/classes/java/util/Timer.java b/src/share/classes/java/util/Timer.java index 224420972..5c4d3bf71 100644 --- a/src/share/classes/java/util/Timer.java +++ b/src/share/classes/java/util/Timer.java @@ -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(); } /** -- GitLab