mxsm commented on code in PR #3079:
URL: 
https://github.com/apache/incubator-eventmesh/pull/3079#discussion_r1102228907


##########
eventmesh-common/src/main/java/org/apache/eventmesh/common/utils/ThreadUtils.java:
##########
@@ -20,22 +20,45 @@
 import org.apache.logging.log4j.util.ProcessIdUtil;
 
 import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.TimeUnit;
 
 public class ThreadUtils {
 
     private static volatile long currentPID = -1;
 
-    public static void randomSleep(int min, int max) throws Exception {
-        // nextInt is normally exclusive of the top value, so add 1 to make it 
inclusive
-        int random = ThreadLocalRandom.current().nextInt(min, max + 1);
-        Thread.sleep(random);
+    public static void randomSleep(long min, long max) {
+        randomSleep(min, max, TimeUnit.MILLISECONDS);
+    }
 
+    public static void randomSleep(long min, long max, TimeUnit timeUnit) {
+        // nextInt is normally exclusive of the top value, so add 1 to make it 
inclusive
+        try {
+            long timeout = ThreadLocalRandom.current().nextLong(min, max + 1);
+            timeUnit.sleep(timeout);
+        } catch (InterruptedException ignore) {
+            //ignore
+        }
     }
 
-    public static void randomSleep(int max) throws Exception {
+    public static void randomSleep(long max) {

Review Comment:
   > Suggest to rename method will be better.
   
   @jonyangx Good idea, I will do and resubmit the pr later



-- 
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.

To unsubscribe, e-mail: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to