stefan-egli commented on code in PR #6:
URL: 
https://github.com/apache/sling-org-apache-sling-commons-scheduler/pull/6#discussion_r1869116858


##########
src/main/java/org/apache/sling/commons/scheduler/impl/QuartzThreadPool.java:
##########
@@ -67,8 +72,23 @@ public void setInstanceName(final String name) {
      */
     @Override
     public boolean runInThread(final Runnable job) {
-        this.executor.execute(job);
-
+        synchronized ( this.lock ) {
+            if ( this.counter == 0 ) {
+                return false;
+            }
+            this.counter--;
+        }
+        final Runnable r = () -> {
+            try {
+                job.run();
+            } finally {
+                synchronized ( this.lock ) {
+                    this.counter++;
+                    this.lock.notify();
+                }    
+            }
+        };
+        this.executor.execute(r);

Review Comment:
   good point, it wouldn't be well-defined in what state the runnable is



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

Reply via email to