public final class BackgroundResourceReleaser extends Object
Closing in the background reduces worst case pause times because the caller does not have to perform the tidy up work. The behaviour is controlled by two system properties:
background.releaser — set to false to disable
queuing and release resources on the caller's thread.background.releaser.thread — set to false to queue
work but require manual calls to releasePendingResources().Example usage:
MyCloseable closeable = new MyCloseable();
BackgroundResourceReleaser.release(closeable);
| 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 © 2026 Chronicle Software Ltd. All rights reserved.