mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-24 14:49:58 +00:00
6730380: java.util.Timer should use AtomicInteger
Reviewed-by: dl, chegar
This commit is contained in:
parent
3e4831d05d
commit
731e9ea8a9
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user