nickwongwong commented on a change in pull request #6729:
URL: https://github.com/apache/skywalking/pull/6729#discussion_r612262479



##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/ids/GlobalIdGenerator.java
##########
@@ -74,11 +73,11 @@ private long timestamp() {
 
             if (currentTimeMillis < lastTimestamp) {
                 // Just for considering time-shift-back by Ops or OS. 
@hanahmily 's suggestion.
-                if (runRandomTimestamp != currentTimeMillis) {
-                    lastRandomValue = ThreadLocalRandom.current().nextInt();
-                    runRandomTimestamp = currentTimeMillis;
+                if (lastShiftTimestamp != currentTimeMillis) {
+                    lastShiftValue++;

Review comment:
       对于每一次调用`GlobalIdGenerator.generate()`,都是获取当前线程的`ThreadLocal 
`对应的`IDContext`,也就说每个线程获取的`IDContext`都是自己独有的,不会存在并发问题。
   `IDContext`不存在并发问题的话,显然,其中的`lastShiftValue`也不会。
   
   For each call to `GlobalIdGenerator.generate()`, the `IDContext` 
corresponding to the `ThreadLocal` of the current thread is obtained. In other 
words, the `IDContext` obtained by each thread is unique to itself, and there 
will be no concurrency problems. 
   If there is no concurrency problem with `IDContext`, obviously, the 
`lastShiftValue` in it will not.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to