/** Since we can't guarantee WHEN finalize is called, we may recycle on our own. */ public void reset() throws Exception { synchronized (globalSync) { nativeDestroyPoller(handle); this.handle = nativeCreatePoller(-1); } }
/** Needed to clean up at the JNI C level when object is GCd. */ protected void finalize() throws Throwable { synchronized (globalSync) { nativeDestroyPoller(handle); super.finalize(); } }