The run () method is not called
import java.io.File; public class Delete extends Thread { public static void main(String[] args) { Delete a = new Delete(); a.start(); } public void run() { String fileName = "C:\\temp\\todelete.txt"; File f = new File(fileName); if (!f.exists()) throw new IllegalArgumentException("Delete: no such file or directory: " + fileName); if (!f.canWrite()) throw new IllegalArgumentException("Delete: write protected: " + fileName); if (f.isDirectory()) { String[] files = f.list(); if (files.length > 0) throw new IllegalArgumentException("Delete: directory not empty: " + fileName); } boolean success = f.delete(); if (!success) throw new IllegalArgumentException("Delete: deletion failed"); } }
source share