Top Inners Fields Constructors Methods
com.mchange.v2.async

public final Class ThreadPoolAsynchronousRunner

extends Object
implements ThreadPoolReportingAsynchronousRunner
Class Inheritance
All Implemented Interfaces
com.mchange.v2.async.ThreadPoolReportingAsynchronousRunner, com.mchange.v2.async.AsynchronousRunner, com.mchange.v1.util.ClosableResource
Imports
java.util.*, .Random, com.mchange.v2.log.*, java.io.StringWriter, .PrintWriter, .IOException, java.lang.reflect.Method, com.mchange.v2.io.IndentedWriter, com.mchange.v2.util.ResourceClosedException

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
pack-priv HashSet<E>
pack-priv boolean
pack-priv int
pack-priv TimerTask
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv int
pack-priv static final MLogger
pack-priv HashSet<E>
pack-priv int
pack-priv Timer
pack-priv int
pack-priv LinkedList<E>
pack-priv static final int
pack-priv static final long
pack-priv TimerTask
pack-priv Random
pack-priv boolean
pack-priv Map<K, V>
pack-priv String

Constructor Summary

AccessConstructor and Description
private
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer, boolean should_cancel_timer, String threadLabel)

private
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer, boolean should_cancel_timer)

public
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer, String threadLabel)

public
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer)

public
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, String threadLabel)

public
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock)

public
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, Timer sharedTimer, String threadLabel)

public
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, Timer sharedTimer)

public
ThreadPoolAsynchronousRunner(int num_threads, boolean daemon)

Method Summary

Modifier and TypeMethod and Description
private void
public void
close(boolean
Should be regarded as a hint, not a guarantee. If true, pending, not-yet-performed tasks will be skipped, if possible. Currently executing tasks may or may not be interrupted. If false, all previously scheduled tasks will be completed prior to clean-up. The method returns immediately regardless.
skip_remaining_tasks
)

Implements com.mchange.v2.async.AsynchronousRunner.close.

Finish with this AsynchronousRunner, and clean-up any Threads or resources it may hold.

public void
close()

Implements com.mchange.v2.async.AsynchronousRunner.close.

Clean-up resources held by this asynchronous runner as soon as possible.

private void
public synchronized int
public synchronized int
private String
getJvmStackTraces(int initial_indent)

public synchronized String
private String
getMultiLineStatusString(int initial_indent)

public synchronized int
public synchronized String
private String
getStackTraces(int initial_indent)

public synchronized String
public synchronized int
public synchronized void
private void
printStackTraces(IndentedWriter iw, Object thread, Object[] stackTraces)

private void
private void
private void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

availableback to summary
pack-priv HashSet<E> available
daemonback to summary
pack-priv boolean daemon
deadlock_detector_intervalback to summary
pack-priv int deadlock_detector_interval
deadlockDetectorback to summary
pack-priv TimerTask deadlockDetector
DFLT_DEADLOCK_DETECTOR_INTERVALback to summary
pack-priv static final int DFLT_DEADLOCK_DETECTOR_INTERVAL
DFLT_INTERRUPT_DELAY_AFTER_APPARENT_DEADLOCKback to summary
pack-priv static final int DFLT_INTERRUPT_DELAY_AFTER_APPARENT_DEADLOCK
DFLT_MAX_EMERGENCY_THREADSback to summary
pack-priv static final int DFLT_MAX_EMERGENCY_THREADS
DFLT_MAX_INDIVIDUAL_TASK_TIMEback to summary
pack-priv static final int DFLT_MAX_INDIVIDUAL_TASK_TIME
interrupt_delay_after_apparent_deadlockback to summary
pack-priv int interrupt_delay_after_apparent_deadlock
loggerback to summary
pack-priv static final MLogger logger
managedback to summary
pack-priv HashSet<E> managed
max_individual_task_timeback to summary
pack-priv int max_individual_task_time
myTimerback to summary
pack-priv Timer myTimer
num_threadsback to summary
pack-priv int num_threads
pendingTasksback to summary
pack-priv LinkedList<E> pendingTasks
POLL_FOR_STOP_INTERVALback to summary
pack-priv static final int POLL_FOR_STOP_INTERVAL
PURGE_EVERYback to summary
pack-priv static final long PURGE_EVERY
replacedThreadInterruptorback to summary
pack-priv TimerTask replacedThreadInterruptor
rndback to summary
pack-priv Random rnd
should_cancel_timerback to summary
pack-priv boolean should_cancel_timer
stoppedThreadsToStopDatesback to summary
pack-priv Map<K, V> stoppedThreadsToStopDates
threadLabelback to summary
pack-priv String threadLabel

Constructor Detail

ThreadPoolAsynchronousRunnerback to summary
private ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer, boolean should_cancel_timer, String threadLabel)
ThreadPoolAsynchronousRunnerback to summary
private ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer, boolean should_cancel_timer)
ThreadPoolAsynchronousRunnerback to summary
public ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer, String threadLabel)
ThreadPoolAsynchronousRunnerback to summary
public ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, Timer myTimer)
ThreadPoolAsynchronousRunnerback to summary
public ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock, String threadLabel)
ThreadPoolAsynchronousRunnerback to summary
public ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, int max_individual_task_time, int deadlock_detector_interval, int interrupt_delay_after_apparent_deadlock)
ThreadPoolAsynchronousRunnerback to summary
public ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, Timer sharedTimer, String threadLabel)
ThreadPoolAsynchronousRunnerback to summary
public ThreadPoolAsynchronousRunner(int num_threads, boolean daemon, Timer sharedTimer)
ThreadPoolAsynchronousRunnerback to summary
public ThreadPoolAsynchronousRunner(int num_threads, boolean daemon)

Method Detail

appendStatusStringback to summary
private void appendStatusString(StringBuffer sb)
closeback to summary
public void close(boolean skip_remaining_tasks)

Implements com.mchange.v2.async.AsynchronousRunner.close.

Doc from com.mchange.v2.async.AsynchronousRunner.close.

Finish with this AsynchronousRunner, and clean-up any Threads or resources it may hold.

Parameters
skip_remaining_tasks:boolean

Should be regarded as a hint, not a guarantee. If true, pending, not-yet-performed tasks will be skipped, if possible. Currently executing tasks may or may not be interrupted. If false, all previously scheduled tasks will be completed prior to clean-up. The method returns immediately regardless.

closeback to summary
public void close()

Implements com.mchange.v2.async.AsynchronousRunner.close.

Doc from com.mchange.v2.async.AsynchronousRunner.close.

Clean-up resources held by this asynchronous runner as soon as possible. Remaining tasks are skipped if possible, and any tasks executing when close() is called may or may not be interrupted. Equivalent to close( true ).

ensureReplacedThreadsProcessingback to summary
private void ensureReplacedThreadsProcessing()
getActiveCountback to summary
public synchronized int getActiveCount()

Implements com.mchange.v2.async.ThreadPoolReportingAsynchronousRunner.getActiveCount.

getIdleCountback to summary
public synchronized int getIdleCount()

Implements com.mchange.v2.async.ThreadPoolReportingAsynchronousRunner.getIdleCount.

getJvmStackTracesback to summary
private String getJvmStackTraces(int initial_indent)
getMultiLineStatusStringback to summary
public synchronized String getMultiLineStatusString()
getMultiLineStatusStringback to summary
private String getMultiLineStatusString(int initial_indent)
getPendingTaskCountback to summary
public synchronized int getPendingTaskCount()

Implements com.mchange.v2.async.ThreadPoolReportingAsynchronousRunner.getPendingTaskCount.

getStackTracesback to summary
public synchronized String getStackTraces()

Implements com.mchange.v2.async.ThreadPoolReportingAsynchronousRunner.getStackTraces.

getStackTracesback to summary
private String getStackTraces(int initial_indent)
getStatusback to summary
public synchronized String getStatus()

Implements com.mchange.v2.async.ThreadPoolReportingAsynchronousRunner.getStatus.

getThreadCountback to summary
public synchronized int getThreadCount()

Implements com.mchange.v2.async.ThreadPoolReportingAsynchronousRunner.getThreadCount.

postRunnableback to summary
public synchronized void postRunnable(Runnable r)

Implements com.mchange.v2.async.AsynchronousRunner.postRunnable.

printStackTracesback to summary
private void printStackTraces(IndentedWriter iw, Object thread, Object[] stackTraces) throws IOException
processReplacedThreadsback to summary
private void processReplacedThreads()
recreateThreadsAndTasksback to summary
private void recreateThreadsAndTasks()
runInEmergencyThreadback to summary
private void runInEmergencyThread(final Runnable r)
shuttingDownback to summary
private void shuttingDown(ThreadPoolAsynchronousRunner.PoolThread pt)
stopReplacedThreadsProcessingback to summary
private void stopReplacedThreadsProcessing()
com.mchange.v2.async back to summary

pack-priv Class ThreadPoolAsynchronousRunner.DeadlockDetector

extends TimerTask
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv LinkedList<E>
pack-priv LinkedList<E>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

The action to be performed by this timer task.

Inherited from java.util.TimerTask:
cancelscheduledExecutionTime

Field Detail

currentback to summary
pack-priv LinkedList<E> current
lastback to summary
pack-priv LinkedList<E> last

Constructor Detail

DeadlockDetectorback to summary
pack-priv DeadlockDetector()

Method Detail

runback to summary
public void run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

Doc from java.util.TimerTask.run.

The action to be performed by this timer task.

com.mchange.v2.async back to summary

pack-priv Class ThreadPoolAsynchronousRunner.MaxIndividualTaskTimeEnforcer

extends TimerTask
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv String
pack-priv Thread
pack-priv ThreadPoolAsynchronousRunner.PoolThread
pack-priv String

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
MaxIndividualTaskTimeEnforcer(Thread interruptMe, String threadStr, String fixedTaskStr)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

The action to be performed by this timer task.

Inherited from java.util.TimerTask:
cancelscheduledExecutionTime

Field Detail

fixedTaskStrback to summary
pack-priv String fixedTaskStr
interruptMeback to summary
pack-priv Thread interruptMe
ptback to summary
pack-priv ThreadPoolAsynchronousRunner.PoolThread pt
threadStrback to summary
pack-priv String threadStr

Constructor Detail

MaxIndividualTaskTimeEnforcerback to summary
pack-priv MaxIndividualTaskTimeEnforcer(ThreadPoolAsynchronousRunner.PoolThread pt)
MaxIndividualTaskTimeEnforcerback to summary
pack-priv MaxIndividualTaskTimeEnforcer(Thread interruptMe, String threadStr, String fixedTaskStr)

Method Detail

runback to summary
public void run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

Doc from java.util.TimerTask.run.

The action to be performed by this timer task.

com.mchange.v2.async back to summary

pack-priv Class ThreadPoolAsynchronousRunner.PoolThread

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv Runnable
pack-priv int
pack-priv TimerTask
pack-priv boolean
Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv
PoolThread(int index, boolean daemon)

Method Summary

Modifier and TypeMethod and Description
private void
pack-priv void
pack-priv Runnable
public int
private void
public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

private void
Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

currentTaskback to summary
pack-priv Runnable currentTask
indexback to summary
pack-priv int index
maxIndividualTaskTimeEnforcerback to summary
pack-priv TimerTask maxIndividualTaskTimeEnforcer
should_stopback to summary
pack-priv boolean should_stop

Constructor Detail

PoolThreadback to summary
pack-priv PoolThread(int index, boolean daemon)

Method Detail

cancelMaxIndividualTaskTimeEnforcerback to summary
private void cancelMaxIndividualTaskTimeEnforcer()
gentleStopback to summary
pack-priv void gentleStop()
getCurrentTaskback to summary
pack-priv Runnable getCurrentTask()
getIndexback to summary
public int getIndex()
purgeTimerback to summary
private void purgeTimer()
runback to summary
public void run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Thread.run.

This method is run by the thread when it executes. Subclasses of Thread may override this method.

This method is not intended to be invoked directly. If this thread is a platform thread created with a Runnable task then invoking this method will invoke the task's run method. If this thread is a virtual thread then invoking this method directly does nothing.

setMaxIndividualTaskTimeEnforcerback to summary
private void setMaxIndividualTaskTimeEnforcer()
com.mchange.v2.async back to summary

pack-priv Class ThreadPoolAsynchronousRunner.ReplacedThreadInterruptor

extends TimerTask
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

The action to be performed by this timer task.

Inherited from java.util.TimerTask:
cancelscheduledExecutionTime

Constructor Detail

ReplacedThreadInterruptorback to summary
pack-priv ReplacedThreadInterruptor()

Method Detail

runback to summary
public void run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

Doc from java.util.TimerTask.run.

The action to be performed by this timer task.