multithreading - Running multiple threads concurrently in java -


i have run 2 threads concurrently 1 prints numbers 1 500 whereas prints numbers 501 1000. output must show concurrency.

try below code. main thread prints numbers 1 500 , other thread prints there on 1000.

public class test  implements runnable{      public static void main(string[] args) throws exception {         thread t = new thread(new test());         t.start();         (int = 1 ; <=500 ; i++)             system.out.println("main thread printing "+i);     }      @override     public void run() {         (int i=501; <=1000 ; i++)              system.out.println("thread 1 printing "+i);     }  } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -