Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Is there any way I can spawn a Thread to execute a static method?



For instance, I want to do something like this.

File src = new File("C:\\src.txt");
File dst = new File("C:\\dst.txt");
FileManager.copyFile(src, dst);

However, I want copyFile to run in it's own thread so my program can continue functioning. I know workarounds using temporary instantiation such as... (assuming FileManager extends Thread);

command c = "copy";
new FileManager(c, src, dest).start();

but doing it that way is clumsy and requires more code and more room for error (and variables I won't use). Any help?