2

What is the difference between ThreadPool and ThreadExecutor in the Quartz framework?

You can configure it in the quartz.properties like this:

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5

org.quartz.threadExecutor.class = org.quartz.commonj.WorkManagerThreadExecutor

I don't understand it. Looking at the org.quartz.commonj.WorkManagerThreadExecutor, it just looks for the commonj.work.WorkManager from jndi and then runs job tasks using that manager.

AFIK, you can configure thread count etc when declaring the commonj.work.WorkManager in JNDI context. Something like this

<Resource auth="Container" 
          factory="de.myfoo.commonj.work.FooWorkManagerFactory"
          maxThreads="2" 
          minThreads="1" 
          name="wm/workManager"
          type="commonj.work.WorkManager" />
keuleJ
  • 3,418
  • 4
  • 30
  • 51
Jan Krakora
  • 2,500
  • 3
  • 25
  • 52

1 Answers1

2

The difference is that threads provided by the SimpleThreadPool (or any other thread pool implementation configured in your Quartz properties) are unmanaged threads, i.e. threads that are not managed by your container.

On the other hand, threads provided by the configured work manager are managed threads created by the container and typically configured through the container's admin console.

In J2EE world creating unmanaged threads is generally highly discouraged and if you check the J2EE spec, you will find it is explicitly mentioned there (or it used to be there).

You may want to check this SO post for further details on the topic.

Community
  • 1
  • 1
Jan Moravec
  • 1,808
  • 1
  • 15
  • 18
  • 1
    Yes, but do I need define both of them? ThreadPool and ThreadExecutor? What if I define only the ThreadExecutor and what if I define both of them? There is no info about the ThreadExecutor in the Quartz documentation at all. – Jan Krakora Dec 18 '14 at 10:31
  • If you check the Quartz scheduler API (http://quartz-scheduler.org/api/2.2.0/org/quartz/spi/ThreadExecutor.html), you will find out the ThreadExecutor is a SPI that allows Quartz to hide thread-pool implementation details. You never specify both org.quartz.threadPool and org.quartz.threadExecutor Quartz config properties. If you want to use a thread pool with unmanaged threads, you will use org.quartz.threadPool.* properties, otherwise use org.quartz.threadExecutor.* properties if you want to make use of a CommonJ work manager (think a thread-pool) provided by your J2EE container. – Jan Moravec Dec 18 '14 at 14:49