Any concept of shared memory in Java

后端 未结 10 522
猫巷女王i
猫巷女王i 2020-11-29 05:33

AFAIK, memory in Java is based on heap from which the memory is allotted to objects dynamically and there is no concept of shared memory.

If there is no concept of s

10条回答
  •  抹茶落季
    2020-11-29 06:07

    Since there is no official API to create a shared memory segment, you need to resort to a helper library/DDL and JNI to use shared memory to have two Java processes talk to each other.

    In practice, this is rarely an issue since Java supports threads, so you can have two "programs" run in the same Java VM. Those will share the same heap, so communication will be instantaneous. Plus you can't get errors because of problems with the shared memory segment.

提交回复
热议问题