File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes Multiple processes accessing single class data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Multiple processes accessing single class data" Watch "Multiple processes accessing single class data" New topic

Multiple processes accessing single class data

Minseong Kim

Joined: Jun 28, 2010
Posts: 5

so, what i want to do is..

for example,

if there is, and,

and each java source file has main classes, and when compiled, load as an individual program.

let's say there is a deque in

what i want to do is to allow and accesses to the same deque(same memory space; i am not talking about creating instances; I want to access to the same memory) in

how am I able to do this?

If this is possible, are and allowed to operate together? (I mean whether these two programs can work at the same time toward the deque.)


Unmesh Chowdhury
Ranch Hand

Joined: Jun 20, 2010
Posts: 45
You can try with the following three classes:

To test the above classes you may use the following fragment of code:

M.Sc. in CS, OCPJP6 93%
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 597

Unmesh Chowdhury wrote:You can try with the following three classes:

Thats a nice example.

I was wondering if its possible to have the push logic in the push class and pop logic in the pop class and still access the shared resource. To answer my own question we could synchronize on the resource itself,
Something like
push or pop logic

I assume thats what the original question was leaning towards.

Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

Yes, you can access the same memory. Java has a shared memory model.
See java doc for some information
and see Java and C++ example for an example.
subject: Multiple processes accessing single class data
Similar Threads
call to JTextArea.getText() is not getting current text
Calling constructors of inherited classes
Accessing component from main class.... Help!
Compiling many classes
ant-classpath- FileNotFoundException