Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Compare java instances

Thread view: 
Robina Brintha - 10 Apr 2007 14:06 GMT
Hi all,

I am quite new to Java.

I have an issue to be solved. I want to compare two JVM instances. Let
me go in detail I am instantiating two or more java instances of
particular application and  I wanted to know which java instance
started first. For that I am generating random numbers in the
constructor of the class and trying to store it in a static variable
and comparing this with newly generated randon number. But then it
didnt work.

Is there any other easy solution to do that?

Can anyone give some hint?

Thanks in advance

regards,
robina
Rogan Dawes - 10 Apr 2007 14:12 GMT
> Hi all,
>
[quoted text clipped - 16 lines]
> regards,
> robina

How about storing System.currentTimeMillis()?

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#currentTimeMillis()

I have no idea how you are comparing these numbers, though. Over the
network? Also keep in mind that if you are in different time zones, you
need to account for that.

Rogan
Andrew Thompson - 10 Apr 2007 14:27 GMT
..
>I have an issue to be solved.

What is the issue to be solved?
What ability are you attempting to offer to the end user?
(I trimmed the rest, because you seemed to be
describing a strategy you thought might achieve
the goal, without actually stating what the goal was)

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Robina Brintha - 10 Apr 2007 15:18 GMT
Dear Andrew,

I have an aplication which will be run by different clients at a time.
Each instance will first find if an update is needed through a method
in the application. The instance which finds that first will be the
coordinator who sends message(multicast) to all other instances.

So in this scenario if two instances finds that an update is needed in
exactly the same time they have to compete using some strategy and
agree upon that either one of them who wins the strategy will be the
coordinator who will send update message to all the others in the
group. Its the issue of what strategy can I use to choose coordinator
and how to share that state among other instances? Hope I have
explained bit clear now. Do you have any idea?
Oliver Wong - 10 Apr 2007 16:27 GMT
> Dear Andrew,
>
[quoted text clipped - 10 lines]
> and how to share that state among other instances? Hope I have
> explained bit clear now. Do you have any idea?

   Will the instances be running on the same computer, the same LAN, or
over the internet?

   - Oliver
Robina Brintha - 10 Apr 2007 16:30 GMT
> > Dear Andrew,
>
[quoted text clipped - 15 lines]
>
>     - Oliver

instances run in same computer...
Oliver Wong - 10 Apr 2007 17:12 GMT
>> > I have an aplication which will be run by different clients at a
>> > time.
>> > Each instance will first find if an update is needed through a method
>> > in the application. The instance which finds that first will be the
>> > coordinator who sends message(multicast) to all other instances.

[...]
>>     Will the instances be running on the same computer, the same LAN,
>> or
>> over the internet?
>
> instances run in same computer...

   Simplest solution is to try to acquire an exclusive resource in an
atomic fashion, and the first process to have successfully required this
resource is the "first" instance, and can act as the server or coordinator
or whatever.

   Example include listening on a specific port or trying to gain
exclusive write-access to a specific file.

   - Oliver
Andrew Thompson - 11 Apr 2007 01:54 GMT
...
>I have an aplication which will be run by different clients at a time.

You mention later that this will all be happening on one
single PC.  *

>Each instance will first find if an update is needed through a method
>in the application. The instance which finds that first will be the
>coordinator who sends message(multicast) to all other instances.

* If that is the case, you might use the JNLP based SingleInstanceService **
to open a 'controller' application that launches a single screen of the
'user visible area' (AKA 'the application').   Later invocations will
'report to' that first controller instance, so it is possible to open
other UVA's as needed, while the controller is overseeing updates for
all.

** Here is an example <http://www.physci.org/jws/#sis>

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.