@Stability.Internal public class Jdk8Cleaner extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Jdk8Cleaner.Cleanable
An object and a cleaning action registered in a Cleaner.
|
Modifier and Type | Method and Description |
---|---|
static Jdk8Cleaner |
create(ThreadFactory factory) |
Jdk8Cleaner.Cleanable |
register(Object obj,
Runnable cleaningAction)
Executes the given cleaning action when the object becomes phantom reachable.
|
static void |
registerWithOneShotCleaner(Object obj,
Runnable cleanupTask)
Creates a new cleaner, and registers the given cleanup action to run
when the given object becomes phantom reachable.
|
public static Jdk8Cleaner create(ThreadFactory factory)
public static void registerWithOneShotCleaner(Object obj, Runnable cleanupTask)
The cleaner's thread terminates after the given cleanup task is executed.
The cleaning action should generally not be a lambda, since it's easy to accidentally capture a reference to the object, preventing it from ever becoming phantom reachable.
public Jdk8Cleaner.Cleanable register(Object obj, Runnable cleaningAction)
The cleaning action should generally not be a lambda, since it's easy to accidentally capture a reference to the object, preventing it from ever becoming phantom reachable.
Copyright © 2024 Couchbase, Inc.. All rights reserved.