using shared memory in Java
2 posts in topic
Flat View  Flat View

Posted By:   Alex_Suna
Posted On:   Friday, August 2, 2002 07:21 AM

How can I use a shared memory zone that can be readed or/and writed by 2 or more independents threads ?

Re: using shared memory in Java

Posted By:   chris_moran  
Posted On:   Sunday, September 1, 2002 02:24 PM

There are a couple ways that you can implement this.

1. Use SDK 1.4.1 and in it is the Shared Memory classes.
I cannot remember which library they are in.

2. If all the independent threads you are speaking of
reside in the same JVM, there is a very elegant way of
executing exactly what you want. Create a static queue
that all the threads may access. Control the Thread(s)
access to the Queue through synchronization on the recv()
method of the queue. If the queue is empty.. make the
thread block by 'wait'ing. Whenever any thread adds to the
queue.. that thread calls notify on the queue thus waking
up a 'wait'ing thread. This can be modified in a similar
way for the access of arrays.

Good Luck

Re: using shared memory in Java

Posted By:   Christopher_Koenigsberg  
Posted On:   Friday, August 2, 2002 07:24 AM

Member variables of a class are shared by all the threads in the class.

About | Sitemap | Contact