Skip to content

io microsphere util ShutdownHookCallbacksThread

github-actions[bot] edited this page Mar 24, 2026 · 4 revisions

ShutdownHookCallbacksThread

Type: Class | Module: microsphere-java-core | Package: io.microsphere.util | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/util/ShutdownHookCallbacksThread.java

Overview

A Thread that executes registered shutdown hook Runnable callbacks when the JVM begins its shutdown sequence.

Example Usage

`// This thread is used internally by ShutdownHookUtils:
  // ShutdownHookUtils.addShutdownHookCallback(() -> System.out.println("Shutting down..."));
  // The ShutdownHookCallbacksThread will execute all registered callbacks on JVM shutdown.
`

Declaration

class ShutdownHookCallbacksThread extends Thread

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.2-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

// This thread is used internally by ShutdownHookUtils:
  // ShutdownHookUtils.addShutdownHookCallback(() -> System.out.println("Shutting down..."));
  // The ShutdownHookCallbacksThread will execute all registered callbacks on JVM shutdown.

Method Examples

run

// Internally constructed as a singleton:
  // ShutdownHookCallbacksThread thread = new ShutdownHookCallbacksThread();
  // thread.getName(); // "ShutdownHookCallbacksThread"
// This method is invoked automatically by the JVM during shutdown:
  // Runtime.getRuntime().addShutdownHook(ShutdownHookCallbacksThread.INSTANCE);
  // All registered callbacks in ShutdownHookUtils.shutdownHookCallbacks will be executed.

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.util.ShutdownHookCallbacksThread;

API Reference

Public Methods

Method Description
run The singleton instance of ShutdownHookCallbacksThread

Method Details

run

public void run()

The singleton instance of ShutdownHookCallbacksThread / static final ShutdownHookCallbacksThread INSTANCE = new ShutdownHookCallbacksThread();

/** Constructs a new ShutdownHookCallbacksThread with a default thread name derived from the class simple name.

Example Usage

`// Internally constructed as a singleton:
  // ShutdownHookCallbacksThread thread = new ShutdownHookCallbacksThread();
  // thread.getName(); // "ShutdownHookCallbacksThread"
`

Since: 1.0.0

See Also

  • ShutdownHookUtils#registerShutdownHook()

This documentation was auto-generated from the source code of microsphere-java.

Home

annotation-processor

java-annotations

java-core

java-test

jdk-tools

lang-model

Clone this wiki locally