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

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -