java - Do threads ever commit suicide or stop running -


when thread stop running , stop existing? stop running after printing number 10? available garbage collection after printing 10? or must explicitly interrupt or something?

runnable counter = new runnable() {   @override   public void run() {     (int =0; i<=10; i++) {       system.out.println(i);     }   } }; new thread(counter).start(); 

a thread doesn't commit suicide. terminates or gets aborted (say, killed).

there important factor justifies usage of brutal term, killing, process , threads: state not saved , transactional integrity not directly guaranteed unless have mechanism.

in case, thread print 1 10 , terminate, being garbaged next time gc runs.

nothing more.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -