Skip to content

Commit

Permalink
feature:seata-common
Browse files Browse the repository at this point in the history
  • Loading branch information
lightClouds917 committed Dec 24, 2024
1 parent 99c514a commit 0142110
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
*/
package org.apache.seata.common.util;

import org.apache.seata.common.lock.ResourceLock;

/**
* The type Uuid generator.
*/
public class UUIDGenerator {

private static volatile IdWorker idWorker;
private final static ResourceLock RESOURCE_LOCK = new ResourceLock();

/**
* generate UUID using snowflake algorithm
Expand All @@ -30,7 +33,7 @@ public class UUIDGenerator {
*/
public static long generateUUID() {
if (idWorker == null) {
synchronized (UUIDGenerator.class) {
try (ResourceLock ignored = RESOURCE_LOCK.obtain()) {
if (idWorker == null) {
init(null);
}
Expand Down

0 comments on commit 0142110

Please sign in to comment.