Github user HeartSaVioR commented on a diff in the pull request:
https://github.com/apache/storm/pull/2241#discussion_r158679185
--- Diff: storm-client/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -328,20 +328,22 @@ public static boolean isSystemId(String id) {
* @return the newly created thread
* @see Thread
*/
- public static SmartThread asyncLoop(final Callable afn,
- boolean isDaemon, final Thread.UncaughtExceptionHandler eh,
- int priority, final boolean isFactory, boolean
startImmediately,
- String threadName) {
+ public static SmartThread asyncLoop(final Callable afn, boolean
isDaemon, final Thread.UncaughtExceptionHandler eh,
+ int priority, final boolean
isFactory, boolean startImmediately,
+ String threadName) {
SmartThread thread = new SmartThread(new Runnable() {
public void run() {
- Object s;
try {
- Callable fn = isFactory ? (Callable) afn.call() : afn;
- while ((s = fn.call()) instanceof Long) {
- Time.sleepSecs((Long) s);
+ final Callable<Long> fn = isFactory ? (Callable<Long>)
afn.call() : afn;
+ while (true) {
+ final Long s = fn.call();
+ if (s==null) // then stop running it
+ break;
+ if (s>0)
+ Thread.sleep(s);
--- End diff --
Please use `Time.sleepSecs()` for simulated time.
---