(Object obj, Runnable cleanupTask)
| 53 | } |
| 54 | |
| 55 | public synchronized Cleanable register(Object obj, Runnable cleanupTask) { |
| 56 | // The important side effect is the PhantomReference, that is yielded |
| 57 | // after the referent is GCed |
| 58 | return add(new CleanerRef(this, obj, referenceQueue, cleanupTask)); |
| 59 | } |
| 60 | |
| 61 | private synchronized CleanerRef add(CleanerRef ref) { |
| 62 | synchronized (referenceQueue) { |