public final class BackgroundResourceReleaser extends Object
This class helps in releasing the resources in the background when they are no longer needed. It internally uses a background thread to perform the releasing operations. The background thread can be disabled if needed by using system properties.
| Modifier and Type | Field and Description |
|---|---|
static String |
BACKGROUND_RESOURCE_RELEASER |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isOnBackgroundResourceReleaserThread()
Checks if the current thread is the background resource releaser thread.
|
static void |
release(AbstractCloseable closeable)
Releases the specified closeable resource.
|
static void |
release(AbstractReferenceCounted referenceCounted)
Releases the specified reference counted resource.
|
static void |
releasePendingResources()
Releases all pending resources.
|
static void |
run(Runnable runnable)
Executes the specified runnable to release the resource.
|
static void |
stop()
Stops the background releasing thread after releasing pending resources.
|
public static final String BACKGROUND_RESOURCE_RELEASER
public static void stop()
It should be called during the shutdown process to release any resources that have not been released yet.
public static void release(AbstractCloseable closeable)
closeable - the resource to releasepublic static void release(AbstractReferenceCounted referenceCounted)
referenceCounted - the resource to releasepublic static void run(Runnable runnable)
runnable - the runnable to execute for releasing the resourcepublic static void releasePendingResources()
Should be called when you want to make sure that all the resources that have been queued for release are actually released.
public static boolean isOnBackgroundResourceReleaserThread()
Copyright © 2024. All rights reserved.