Do you have any test to show the performance difference ?
I see a possible race condition where the system would starve.
The synchronized here is protecting both running and tasks.. that means.. you wouldn't have running=false while still having tasks.
You could have a case where running=false and you still have tasks... and the system would starve until you executed something else. Which will be fine for most of the time, but it could cause issues when you have low throuput.
To fix that the class could retry on a synchronized...
I have your fix with this latest change here: https://github.com/clebertsuconic/hornetq/blob/d98f4b8a16d04af81207399ea141208a37e7a0a4/hornetq-core-client/src/main/java/org/hornetq/utils/OrderedExecutorFactory.java
thanks for the change BTW: I will edit the commit later to reflect your name on the contribution.
Thanks Clebert for review and the additional changes.
Currently on vacation, will look into it again in January and provide feedback.
Tested your version and works well - thanks