public class CloseWatcher extends PhantomReference<Object>
| 构造器和说明 |
|---|
CloseWatcher(Object referent,
ReferenceQueue<Object> q,
AutoCloseable closeable) |
| 限定符和类型 | 方法和说明 |
|---|---|
AutoCloseable |
getCloseable() |
String |
getOpenStackTrace()
Get the open stack trace or null if none.
|
static CloseWatcher |
pollUnclosed()
Check for an collected object.
|
static CloseWatcher |
register(Object o,
AutoCloseable closeable,
boolean stackTrace)
Register an object.
|
static void |
unregister(CloseWatcher w)
Unregister an object, so it is no longer tracked.
|
getclear, enqueue, isEnqueuedpublic CloseWatcher(Object referent, ReferenceQueue<Object> q, AutoCloseable closeable)
public static CloseWatcher pollUnclosed()
public static CloseWatcher register(Object o, AutoCloseable closeable, boolean stackTrace)
o - the objectcloseable - the object to closestackTrace - whether the stack trace should be registered (this is
relatively slow)public static void unregister(CloseWatcher w)
w - the referencepublic String getOpenStackTrace()
public AutoCloseable getCloseable()
Copyright © 2022. All rights reserved.