FAQs

Frequently Asked Questions - thread

FAQs - thread

Absolutely. However you need to modify your job implementation class a bit so that QuartzDesk can associate the spawned worker threads with the correct job execution thread.

If your Quartz job implementation class uses the Java Executor API and worker threads that do not produce Future results:

public class MyJob 
    implements Job 
{
  ... 

  public void execute(JobExecutionContext context) 
      throws JobExecutionException 
  { 
    ...
    Executor executor = ... // get a Java Executor 
    executor.execute( new WorkerThreadRunnable( Thread.currentThread(), YourRunnableInstance ) ); 
    ...
  }

  ... 
}

If your Quartz job implementation class uses the Java ExecutorService API and worker threads that produce Future results:

public class MyJob 
    implements Job 
{ 
  ... 

  public void execute(JobExecutionContext context) 
      throws JobExecutionException 
  { 
    ... 
    ExecutorService executorService = ... // get a Java ExecutorService
    Future result = executor.submit( new WorkerThreadCallable( Thread.currentThread(), YourCallableInstance ) ); 
    ...
  } 

  ... 
}

As shown in the above examples, you need to wrap the worker thread's body in either a WorkerThreadRunnable, or WorkerThreadCallable instance. WorkerThreadRunnable and WorkerThreadCallable classes are provided by the QuartzDesk Public API Library (quartzdesk-api.jar) and in order to use these classes in your application, you must add the QuartzDesk Public API Library to your application as a compile-time dependency.If you application uses Maven, you need to add the following to your project POM's dependencies:

<dependency>
  <groupId>com.quartzdesk</groupId>
  <artifactId>quartzdesk-api</artifactId>
  <version>x.y.z</version>
  <scope>compile</scope>
</dependency>