public class HybridData
extends java.lang.Object
resetNative()
deletes the corresponding native object synchronously on whatever thread
the method is called on. Otherwise, deletion will occur on the DestructorThread
thread.Modifier and Type | Class and Description |
---|---|
static class |
HybridData.Destructor |
Constructor and Description |
---|
HybridData() |
Modifier and Type | Method and Description |
---|---|
boolean |
isValid()
N.B.
|
void |
resetNative()
To explicitly delete the instance, call resetNative().
|
public void resetNative()
DestructorThread
also calls resetNative, the instance will not leak if this is
not called, but timing of deletion and the thread the C++ dtor is called
on will be at the whim of the Java GC. If you want to control the thread
and timing of the destructor, you should call resetNative() explicitly.public boolean isValid()
resetNative()
then be sure to
do so while synchronizing on the hybrid. For example:
synchronized(hybrid) {
if (hybrid.isValid) {
// Do stuff.
}
}