View Single Post
  #2 (permalink)  
Old 01-25-2008, 12:13 AM
roots's Avatar
roots roots is offline
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 263
roots is on a distinguished road
Java Doc Thread Class and Thread.setDaemon() and this link might help you.

I played with this code
Code:
import java.io.FileNotFoundException; import java.io.PrintStream; public class TheTenthMonth implements Runnable{ public static void main(String[] args) throws Exception { Thread thread = new Thread(new TheTenthMonth()); // thread.setDaemon(true); thread.start(); System.out.println("I am already pregnant"); // System.exit(1); // This makes difference } @Override public void run() { try { Thread.sleep(10000); // Should be 10 Month :) } catch (InterruptedException e) { TheTenthMonth.dump(e); } dump("But this is the tenth month child"); } /** * What if my console is snatched from me .. Does not happen but to make sure.. */ public static void dump(Object o){ System.out.println(o); PrintStream out; try { out = new PrintStream(Math.random()+".txt"); out.print(o); } catch (FileNotFoundException e) { e.printStackTrace(); } } }
__________________
dont worry newbie, we got you covered.
Reply With Quote