Michael Koch wrote:
Am Montag, 17. Mai 2004 12:40 schrieb Jeroen Frijters:
Michael Koch wrote:
The attached patch written by Guilhem Lavaux implements
File.deleteOnExit() in an easy way.
Ok to commit ?
It doesn't make me happy to preallocate all these objects (and in
general, the less static initializers the better). Shouldn't we
just move DeleteFileHelper to gnu.java.io (or whatever) and make it
a proper singleton? That way the singleton will be allocated lazily
upon first use of File.deleteOnExit().
Here is a revised patch for review:
Thanks! I think it would be slightly better to do:
+public final class DeleteFileHelper extends Thread
+{
+ private static LinkedList filesToDelete = new LinkedList();
+
+ static
+ {
+ Runtime.getRuntime().addShutdownHook(new DeleteFileHelper());
+ }
+
+ public static void add(File file)
+ {
+ filesToDelete.add(file);
+ }
+
+ private DeleteFileHelper()
+ {
+ }
Since we already had a static initializer (to initialize the static
filesToDelete field), it's better to leverage it to do the call to
addShutdownHook as well. I also made the constructor private.
Regards,
Jeroen
_______________________________________________
Commit-classpath mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/commit-classpath