Java Inter Process communication and Inter Thread communication?

后端 未结 4 1357
遇见更好的自我
遇见更好的自我 2020-12-29 14:56

What is the difference between a Thread and a Process in the Java context? How is inter-Process communication and inter-Thread communication achieved in Java? Please point m

4条回答
  •  清歌不尽
    2020-12-29 15:59

    I like to think of a single instance of a JVM as a process. So, interprocess communication would be between instances of JVM's, for example, through sockets (message passing).

    Threads in java implement Runnable and are contained within a JVM. They share data simply by passing references in the JVM around. Whenever threads share data you almost always need to protect the data so multiple threads don't clobber each other. There are many mechanisms for protection that all involve preventing multiple threads from entering critical sections of code.

提交回复
热议问题