Simultaneously run java programs run on same JVM?

后端 未结 6 2113
旧巷少年郎
旧巷少年郎 2020-12-08 01:33

Suppose I run two java programs simultaneously on the same machine. Will the programs run in a single instance of JVM or will they run in two different instances of JVM?

6条回答
  •  情话喂你
    2020-12-08 01:56

    What you could do is use two separate threads. For exampe

    new Thread() {
      public void run() {
       System.out.println("this is running separately from the main thread!");
      }
    }.start();
    

    If you want two separate programs to interact you would need to use sockets

提交回复
热议问题