java - Should we explicitly kill a thread? -


i create 3 threads in main program. have loop in each thread. after executing statements in run() method , each thread automatically gets destroyed or killed itself. correct? understanding correct ?

is there java standard reference mentions there no need explicitly kill thread , itself. have been trying read , browse many articles. still not getting 100% confidence.

i highly appreciate if expert on here reply , me out. in advance!!!

public class demo {     testa = new testa("testa",threadalist);     testa b = new testb("testb",threadblist);     testa c = new testc("testc",threadclist); }  class testa implements runnable {     thread t;      public testa(string name,list threadalist) {         system.out.println(name);         this.threadalist = threadalist;         t = new thread(this);         t.start();     }      public void run() {         try {             system.out.println("testa thread started");         }         catch(exception e) {             e.printstacktrace(log);             doing action move faild file failure folder             }         {             log.close();         }     } } 

yes, thread automatically destroyed , made available garbage collection once runnable's run method has returned.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -