example on setDaemon()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Deepak_Gupta
Posted On:   Friday, March 10, 2006 09:17 AM

			
Please give an example on setDaemon().

Re: example on setDaemon()

Posted By:   Almagest_FUTT  
Posted On:   Friday, March 10, 2006 10:40 AM


EXAMPLE
-----------------
|
|
|
|
|
|
-----------------
setDaemon()


Example 1:

public static void main(String[] s){
Thread t = new Thread(){
public void run(){
for(;;){
try{ sleep(2500); } catch(Exception x){}
}
}
};

t.start();
}


Example 2:

public static void main(String[] s){
Thread t = new Thread(){
public void run(){
for(;;){
try{ sleep(2500); } catch(Exception x){}
}
}
};

t.setDaemon(true);
t.start();
}


Try running both, notice the difference.
About | Sitemap | Contact