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
Post a Comment