How Actually start(); works in Java Threading -


here example code:

public class hellorunnable implements runnable {      @override     public void run() {         system.out.println("run entered");     }      public static void main(string args[]) {         thread obj=new thread(new hellorunnable());         obj.start();         system.out.println("abc");     }  } 

output:

abc run entered 

why abc before run()'s code?

even create 3 threads. still abc print first;

obj.start(); obj1.start(); obj2.start(); 

really tried search this, unable find query this.

simply because hellorunnable.run method executed in thread 1 printing abc. execute concurrently, that's point of threads. therefore, of 2 may access resource, stdout, before other.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -