2

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.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • 1
    so no PipedInputsstream? – 11684 Jun 25 '12 at 18:42
  • 1
    maybe these could help: http://stackoverflow.com/questions/1125534/what-is-the-best-way-to-access-memory-in-java-similar-to-mmap http://stackoverflow.com/questions/1491519/any-concept-of-shared-memory-in-java and http://www.coderanch.com/t/441876/java/java/does-java-support-shared-memory – David Kroukamp Jun 25 '12 at 18:50

2 Answers2

2

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.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
1

If you can make one application to launch another via Process API, then they can communicate over standard input an output.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38