Solved

can multiple processes access another class exclusively

Posted on 2004-03-28
5
192 Views
Last Modified: 2010-08-05
hi,
  i have three listener programs running in 3 consoles which listen to different queues.now i have a conection program which i call from my 3 listeners.the problem is that only 1 connection must be made at one time.i tried implementing the connection class as a singleton,but it doesnt work as the 3 listeners operate as 3 diff processes(my understanding).however if i implement all 3 listeners in 1 single program and start 1 program in console then the singleton works fine. so my question is is there a way i can synchronize the connection class from 3 listener programs running seperately in different consoles???  
maybe my understanding is wrong.excuse me if it is.

any help will be highly appreciated... !!!!
0
Comment
Question by:illusionz70
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 10701909
What is it that you want the listener classes to do? And what is the connection program doing? Please explain their functionalities.
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10702063
your 3 programs are running in their own environment.
it's like having them running on 3 different computers.
if you want them to communicate, you'll need some kind of client/server architecture.
you could use RMI to acheive that.
but if it's only to obtain a lock on some process, you could simply use a "file lock".
before your program makes a connection, it can check if the file exists.
if the file does not exist, create a file make your connection and delete the file when you are done.
if the files exists, then wait for it to be deleted by the program that has the lock.
0
 
LVL 13

Accepted Solution

by:
Webstorm earned 175 total points
ID: 10703575
>> but if it's only to obtain a lock on some process, you could simply use a "file lock".
Some synchronization problem will happen :
  P1: file doesn't exist (true)
                     P2:  file doesn't exist (true)
  P1: create the file, use the connection
                     P2: create the file, use the connection

The solution is to use RMI, and use synchronized methods to access the connection.



0
 
LVL 4

Author Comment

by:illusionz70
ID: 10712242
but the connection program is a .java file as well and i need an object or instance of the connection.java ad only 1 listener.java must be able to get access to that instance at a time.is this possible with file locks?????

thanks..for all replies and sorri for my late reply .
0
 
LVL 4

Author Comment

by:illusionz70
ID: 10747323
File locks work on 1.4 ...i am aloowed to use only 1.3.1 . do i have any alternate options or is it possible to import the filelock library in 1.3.1.

i think a filelock server should go well as different processes can get the lock on file by calling this dedicated server...!!!
ne thoughts...???
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jsp insert to database example 2 59
collection output issue 9 59
Running JavaFX on the Raspberry Pi 27 123
batch vs regular insert in spring DAO 2 20
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question