Solved

can multiple processes access another class exclusively

Posted on 2004-03-28
5
189 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now