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


##########
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:
   Maybe, although you might end up with double decrement? What if the runnable 
is executed, runs the finally part and then a RuntimeException is thrown?



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