Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. /**
  2. * General-purpose phantom-reference-based cleaners.
  3. *
  4. * <p> Cleaners are a lightweight and more robust alternative to finalization.
  5. * They are lightweight because they are not created by the VM and thus do not
  6. * require a JNI upcall to be created, and because their cleanup code is
  7. * invoked directly by the reference-handler thread rather than by the
  8. * finalizer thread. They are more robust because they use phantom references,
  9. * the weakest type of reference object, thereby avoiding the nasty ordering
  10. * problems inherent to finalization.
  11. *
  12. * <p> A cleaner tracks a referent object and encapsulates a thunk of arbitrary
  13. * cleanup code. Some time after the GC detects that a cleaner's referent has
  14. * become phantom-reachable, the reference-handler thread will run the cleaner.
  15. * Cleaners may also be invoked directly; they are thread safe and ensure that
  16. * they run their thunks at most once.
  17. *
  18. * <p> Cleaners are not a replacement for finalization. They should be used
  19. * only when the cleanup code is extremely simple and straightforward.
  20. * Nontrivial cleaners are inadvisable since they risk blocking the
  21. * reference-handler thread and delaying further cleanup and finalization.
  22. *
  23. *
  24. * @author Mark Reinhold
  25. */
  26. /*
  27. * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
  28. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  29. *
  30. * This code is free software; you can redistribute it and/or modify it
  31. * under the terms of the GNU General Public License version 2 only, as
  32. * published by the Free Software Foundation. Oracle designates this
  33. * particular file as subject to the "Classpath" exception as provided
  34. * by Oracle in the LICENSE file that accompanied this code.
  35. *
  36. * This code is distributed in the hope that it will be useful, but WITHOUT
  37. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  38. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  39. * version 2 for more details (a copy is included in the LICENSE file that
  40. * accompanied this code).
  41. *
  42. * You should have received a copy of the GNU General Public License version
  43. * 2 along with this work; if not, write to the Free Software Foundation,
  44. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  45. *
  46. * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  47. * or visit www.oracle.com if you need additional information or have any
  48. * questions.
  49. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement