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

public Class ThreadPerTaskAsynchronousRunner

extends Object
implements AsynchronousRunner
Class Inheritance
All Implemented Interfaces
com.mchange.v2.async.AsynchronousRunner, com.mchange.v1.util.ClosableResource
Imports
java.util.*, com.mchange.v2.log.*, com.mchange.v2.util.ResourceClosedException

Nested and Inner Type Summary

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

Field Summary

Modifier and TypeField and Description
pack-priv ArrayList<E>
pack-priv Thread
pack-priv final long
pack-priv Timer
pack-priv static final MLogger
pack-priv final int
pack-priv static final int
pack-priv LinkedList<E>
pack-priv ArrayList<E>
pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
ThreadPerTaskAsynchronousRunner(int max_task_threads)

public
ThreadPerTaskAsynchronousRunner(int max_task_threads, long interrupt_task_delay)

Method Summary

Modifier and TypeMethod and Description
private synchronized void
private synchronized void
public void
close()

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

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

public synchronized 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.

private void
public synchronized int
public synchronized Collection<E>
public synchronized int
public synchronized Collection<E>
private boolean
public synchronized boolean
public synchronized boolean
public synchronized void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

deadlockSnapshotback to summary
pack-priv ArrayList<E> deadlockSnapshot
dispatchThreadback to summary
pack-priv Thread dispatchThread
interrupt_task_delayback to summary
pack-priv final long interrupt_task_delay
interruptAndDeadlockTimerback to summary
pack-priv Timer interruptAndDeadlockTimer
loggerback to summary
pack-priv static final MLogger logger
max_task_threadsback to summary
pack-priv final int max_task_threads
PRESUME_DEADLOCKED_MULTIPLEback to summary
pack-priv static final int PRESUME_DEADLOCKED_MULTIPLE
queueback to summary
pack-priv LinkedList<E> queue
runningback to summary
pack-priv ArrayList<E> running
still_openback to summary
pack-priv boolean still_open

Constructor Detail

ThreadPerTaskAsynchronousRunnerback to summary
public ThreadPerTaskAsynchronousRunner(int max_task_threads)
ThreadPerTaskAsynchronousRunnerback to summary
public ThreadPerTaskAsynchronousRunner(int max_task_threads, long interrupt_task_delay)

Method Detail

acknowledgeCompleteback to summary
private synchronized void acknowledgeComplete(ThreadPerTaskAsynchronousRunner.TaskThread tt)
checkForDeadlockback to summary
private synchronized void checkForDeadlock()
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 ).

closeback to summary
public synchronized 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.

closeThreadResourcesback to summary
private void closeThreadResources()
getRunningCountback to summary
public synchronized int getRunningCount()
getRunningTasksback to summary
public synchronized Collection<E> getRunningTasks()
getWaitingCountback to summary
public synchronized int getWaitingCount()
getWaitingTasksback to summary
public synchronized Collection<E> getWaitingTasks()
hasIdTimerback to summary
private boolean hasIdTimer()
isClosedback to summary
public synchronized boolean isClosed()
isDoneAndGoneback to summary
public synchronized boolean isDoneAndGone()
postRunnableback to summary
public synchronized void postRunnable(Runnable r)

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

com.mchange.v2.async back to summary

pack-priv Class ThreadPerTaskAsynchronousRunner.DispatchThread

extends Thread
Class Inheritance

Field Summary

Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Constructor Detail

DispatchThreadback to summary
pack-priv DispatchThread()

Method Detail

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.

com.mchange.v2.async back to summary

pack-priv Class ThreadPerTaskAsynchronousRunner.TaskThread

extends Thread
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv Runnable
r

Inherited from java.lang.Thread:
MAX_PRIORITYMIN_PRIORITYNORM_PRIORITY

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv Runnable
pack-priv synchronized boolean
pack-priv synchronized void
public void
run()

Overrides java.lang.Thread.run.

Implements java.lang.Runnable.run.

This method is run by the thread when it executes.

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

completedback to summary
pack-priv boolean completed
rback to summary
pack-priv Runnable r

Constructor Detail

TaskThreadback to summary
pack-priv TaskThread(Runnable r)

Method Detail

getTaskback to summary
pack-priv Runnable getTask()
isCompletedback to summary
pack-priv synchronized boolean isCompleted()
markCompletedback to summary
pack-priv synchronized void markCompleted()
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.