Package com.jsql.util

Class ThreadUtil

java.lang.Object
com.jsql.util.ThreadUtil

public final class ThreadUtil extends Object
Utility class managing running threads on which the user can act. It must be noted that as SwingWorker class are used then only 10 jobs can be run at the same time, the 11th will be waiting in the thread pool until one of the 10 actives one is freed.
  • Constructor Details

  • Method Details

    • put

      public void put(AbstractElementDatabase elementDatabase, AbstractSuspendable suspendable)
      Add a job to the list of ongoing tasks. It is used to allow the user to act on the job and stop/pause a running process.
      Parameters:
      elementDatabase - component associated to the active job
      suspendable - active job to act on
    • get

      public AbstractSuspendable get(AbstractElementDatabase elementDatabase)
      Get the task associated to the database component. It's usually done to act on the task like stop/pause the corresponding process, or to check the status of the job.
      Parameters:
      elementDatabase - component associated to the active job
      Returns:
      job currently running
    • remove

      public void remove(AbstractElementDatabase elementDatabase)
      Remove the thread corresponding to the component in order to be garbage collected. The thread should be stopped prior the deletion.
      Parameters:
      elementDatabase - component associated to thread
    • reset

      public void reset()
      Force to stop every threads still running and empty the list where they were instantiated in order to be garbage collected.
    • getExecutor

      public ExecutorService getExecutor(String nameThread)
    • shutdown

      public void shutdown(ExecutorService taskExecutor)