Package com.jsql.util
Class ThreadUtil
java.lang.Object
com.jsql.util.ThreadUtil
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionget
(AbstractElementDatabase elementDatabase) Get the task associated to the database component.getExecutor
(String nameThread) void
put
(AbstractElementDatabase elementDatabase, AbstractSuspendable suspendable) Add a job to the list of ongoing tasks.void
remove
(AbstractElementDatabase elementDatabase) Remove the thread corresponding to the component in order to be garbage collected.void
reset()
Force to stop every threads still running and empty the list where they were instantiated in order to be garbage collected.void
shutdown
(ExecutorService taskExecutor)
-
Constructor Details
-
ThreadUtil
-
-
Method Details
-
put
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 jobsuspendable
- active job to act on
-
get
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
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
-
shutdown
-