[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Declaration and deployment of threads and thread pools i
david.lloyd@jboss.com
do-not-reply at jboss.com
Wed Dec 10 21:33:50 EST 2008
After spending far too long on this problem, the solution I have come up with (this time) is to have an alternate executor implementation which is used when the configuration given is known not to work with TPE. In this case, it is chosen whenever there is a blocking policy in place, but it could be made more (or less) specific if desired.
The alternate implementation is designed to be correct and simple ("SimpleQueueExecutor"); thus it uses a Queue (rather than a BlockingQueue) to hold tasks and simply uses a Lock and Conditions to synchronize and block as needed, in order to allow for atomic "create-thread-or-queue" and "dequeue-or-destroy-thread" operations. It is designed to hold the lock for as small a time as possible (generally just long enough to do a couple field accesses, comparisons, and maybe a queue insert/remove) without making the code too complex. As such it is considerably simpler than ThreadPoolExecutor (less than 600 lines versus approx. 1800), though I won't place any bets as to comparative performance until I can figure out a way to get a somewhat reliable benchmark result. I'll consider it a runaway success if I achieve "approximately similar". In support of this class, there's also a simple bounded, array-backed queue class ("ArrayQueue") since there is (amazingly) no such thing in t!
he JDK.
As for the common-core stuff - I think that (for the most part) the various extensions can work with this pojo-centric design, but maybe not exactly as-is (since there is some tight coupling with ThreadPoolExecutor in a few places that I see from my initial read through it all). For now I think I'll just postpone the issue - at least until I have fulfilled my immediate obligations.
Anyway, here's links to the more interesting points:
http://anonsvn.jboss.org/repos/sandbox/david.lloyd/jboss-threads/trunk/main/src/main/java/org/jboss/threads/SimpleQueueExecutor.java
http://anonsvn.jboss.org/repos/sandbox/david.lloyd/jboss-threads/trunk/jbossmc/src/main/resources/schema/jboss-threads_1_0.xsd
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4195772#4195772
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4195772
More information about the jboss-dev-forums
mailing list