Package com.mysql.cj.jdbc
Class AbandonedConnectionCleanupThread
java.lang.Object
com.mysql.cj.jdbc.AbandonedConnectionCleanupThread
- All Implemented Interfaces:
java.lang.Runnable
public class AbandonedConnectionCleanupThread
extends java.lang.Object
implements java.lang.Runnable
This class implements a thread that is responsible for closing abandoned MySQL connections, i.e., connections that are not explicitly closed.
There is only one instance of this class and there is a single thread to do this task. This thread's executor is statically referenced in this same class.
-
Method Summary
Modifier and Type Method Description static voidcheckedShutdown()Performs a checked shutdown, i.e., the context ClassLoaders from this and the caller thread are checked for consistency prior to performing the shutdown operation.static booleanisAlive()Returns true if the working thread is alive.voidrun()protected static voidtrackConnection(MysqlConnection conn, NetworkResources io)Tracks the finalization of aMysqlConnectionobject and keeps a reference to itsNetworkResourcesso that they can be later released.static voiduncheckedShutdown()Performs an unchecked shutdown, i.e., the shutdown is performed independently of the context ClassLoaders from the involved threads.
-
Method Details
-
run
public void run()- Specified by:
runin interfacejava.lang.Runnable
-
checkedShutdown
public static void checkedShutdown()Performs a checked shutdown, i.e., the context ClassLoaders from this and the caller thread are checked for consistency prior to performing the shutdown operation. -
uncheckedShutdown
public static void uncheckedShutdown()Performs an unchecked shutdown, i.e., the shutdown is performed independently of the context ClassLoaders from the involved threads. -
isAlive
public static boolean isAlive()Returns true if the working thread is alive. It is alive if it was initialized successfully and wasn't shutdown yet.- Returns:
- true if the working thread is alive; false otherwise.
-
trackConnection
Tracks the finalization of aMysqlConnectionobject and keeps a reference to itsNetworkResourcesso that they can be later released.- Parameters:
conn- the Connection object to track for finalizationio- the network resources to close on the connection finalization
-