diff options
Diffstat (limited to 'src/java/com/jogamp')
-rw-r--r-- | src/java/com/jogamp/common/util/RunnableTask.java | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/java/com/jogamp/common/util/RunnableTask.java b/src/java/com/jogamp/common/util/RunnableTask.java index 15da993..f885f46 100644 --- a/src/java/com/jogamp/common/util/RunnableTask.java +++ b/src/java/com/jogamp/common/util/RunnableTask.java @@ -59,25 +59,48 @@ public class RunnableTask implements Runnable { public void run() { ts1 = System.currentTimeMillis(); - try { - runnable.run(); - } catch (Throwable t) { - runnableException = t; - if(!catchExceptions) { - throw new RuntimeException(runnableException); + if(null == notifyObject) { + try { + runnable.run(); + } catch (Throwable t) { + runnableException = t; + if(catchExceptions) { + runnableException.printStackTrace(); + } else { + throw new RuntimeException(runnableException); + } + } finally { + ts2 = System.currentTimeMillis(); } - } finally { - ts2 = System.currentTimeMillis(); - } - if(null != notifyObject) { + } else { synchronized (notifyObject) { - notifyObject.notifyAll(); + try { + runnable.run(); + } catch (Throwable t) { + runnableException = t; + if(catchExceptions) { + runnableException.printStackTrace(); + } else { + throw new RuntimeException(runnableException); + } + } finally { + ts2 = System.currentTimeMillis(); + notifyObject.notifyAll(); + } } } } + /** + * @return True if executed, otherwise false; + */ public boolean isExecuted() { return 0 != ts2 ; } + + /** + * @return A Throwable thrown while execution if any + */ public Throwable getThrowable() { return runnableException; } + public long getTimestampCreate() { return ts0; } public long getTimestampBeforeExec() { return ts1; } public long getTimestampAfterExec() { return ts2; } |