Is there any better/smarter way to put
and get
a boolean value from memory system
, but not using any TCP/UDP
nor local file system
method?
For example: #both running as 1 application separately $ java -cp /var/tmp/J.jar System.Backend $ java -cp /var/tmp/J.jar System.Frontend
Where Backend
does memory allocation, and Frontend reads it on the fly, none of them will be able to use TCP/UDP nor File system.
Advertisement
Answer
AFAIK, The only way to use shared memory in pure Java is to use memory mapped files.
If you want two pieces of code to share memory, the simplest thing to do is to use one JVM. There is rarely a good reason to use more than one JVM with tightly couple code.