Class CleanerService


  • public class CleanerService
    extends java.lang.Object
    The CleanerService aim to replace the use of finalize() method which is deprecated since java 9 Of course you could instantiate your own, but it will create a thread, this class aim to prevent creating threads everytime
    • Constructor Summary

      Constructors 
      Constructor Description
      CleanerService()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void register​(java.lang.Object object, java.lang.Runnable runnable)
      Register a runnable that will be executed when the object is being garbage collected
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CleanerService

        public CleanerService()
    • Method Detail

      • register

        public void register​(java.lang.Object object,
                             java.lang.Runnable runnable)
        Register a runnable that will be executed when the object is being garbage collected
        Parameters:
        object - the object
        runnable - the task to execute