java - Below code runs successfully, so does it mean we can start thread twice? -
below code runs successfully, mean can start thread twice?
public class enu extends thread { static int count = 0; public void run(){ system.out.println("running count "+count++); } public static void main(string[] args) { enu obj = new enu(); obj.run(); obj.start(); } }
output - running count 0 running count 1
no, started new thread once, when called obj.start()
. obj.run()
executes run
method in current thread. doesn't create new thread, , can call many times like.
on other hand, calling obj.start()
more once not possible.
Comments
Post a Comment