Top Description Fields Constructors Methods
com.mchange.v1.lang

public abstract Class GentleThread

extends Thread
Class Inheritance

an abstract Thread class that provides utilities for easily defining Threads with safe versions of the deprecated thread methods stop(), resume(), and start()

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected synchronized void
allowSuspend()

tests whether the thread should suspend, and causes to the thread to pause if appropriate.

public synchronized void
gentleResume()

a safe method for resuming properly implemented GentleThreads

public synchronized void
gentleStop()

a safe method for stopping properly implemented GentleThreads

public synchronized void
gentleSuspend()

a safe method for suspending properly implemented GentleThreads

public abstract void
run()

Redeclares java.lang.Runnable.run.

Overrides java.lang.Thread.run.

This method is run by the thread when it executes.

protected synchronized boolean
shouldStop()

tests whether the thread should stop.

protected synchronized boolean
shouldSuspend()

tests whether the thread should suspend.

Inherited from java.lang.Thread:
activeCountcheckAccessclonecurrentThreaddumpStackenumerategetAllStackTracesgetContextClassLoadergetDefaultUncaughtExceptionHandlergetIdgetNamegetPrioritygetStackTracegetStategetThreadGroupgetUncaughtExceptionHandlerholdsLockinterruptinterruptedisAliveisDaemonisInterruptedisVirtualjoinjoinjoinjoinofPlatformofVirtualonSpinWaitsetContextClassLoadersetDaemonsetDefaultUncaughtExceptionHandlersetNamesetPrioritysetUncaughtExceptionHandlersleepsleepsleepstartstartVirtualThreadstopthreadIdtoStringyield

Field Detail

should_stopback to summary
pack-priv boolean should_stop
should_suspendback to summary
pack-priv boolean should_suspend

Constructor Detail

GentleThreadback to summary
public GentleThread()
GentleThreadback to summary
public GentleThread(String name)

Method Detail

allowSuspendback to summary
protected synchronized void allowSuspend() throws InterruptedException

tests whether the thread should suspend, and causes to the thread to pause if appropriate. Subclasses should call this method periodically in their run method to, um, allow suspension. Threads paused by allowSuspend() will be properly awoken by gentleResume()

See Also
gentleResume
gentleResumeback to summary
public synchronized void gentleResume()

a safe method for resuming properly implemented GentleThreads

gentleStopback to summary
public synchronized void gentleStop()

a safe method for stopping properly implemented GentleThreads

gentleSuspendback to summary
public synchronized void gentleSuspend()

a safe method for suspending properly implemented GentleThreads

runback to summary
public abstract void run()

Redeclares java.lang.Runnable.run.

Overrides java.lang.Thread.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.

shouldStopback to summary
protected synchronized boolean shouldStop()

tests whether the thread should stop. Subclasses should call this method periodically in their run method, and return from run() is the method returns true.

shouldSuspendback to summary
protected synchronized boolean shouldSuspend()

tests whether the thread should suspend. Subclasses rarely call this method directly, and should call allowSuspend() periodically instead.

See Also
allowSuspend