Class DeleteOnExit

java.lang.Object
java.lang.Thread
org.apache.harmony.luni.util.DeleteOnExit
All Implemented Interfaces:
Runnable

public class DeleteOnExit
extends Thread
Implements the actual DeleteOnExit mechanism. Is registered as a shutdown hook in the Runtime, once it is actually being used.
  • Constructor Details

    • DeleteOnExit

      public DeleteOnExit()
  • Method Details

    • getInstance

      public static DeleteOnExit getInstance()
      Returns our singleton instance, creating it if necessary.
    • addFile

      public void addFile​(String filename)
      Schedules a file for deletion.
      Parameters:
      filename - The file to delete.
    • run

      public void run()
      Does the actual work. Note we (a) first sort the files lexicographically and then (b) delete them in reverse order. This is to make sure files get deleted before their parent directories.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
      See Also:
      Thread.start()