Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Regarding running multiple instances of an application 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 » Java in General
Bookmark "Regarding running multiple instances of an application" Watch "Regarding running multiple instances of an application" New topic
Author

Regarding running multiple instances of an application

Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Hi Ranchers,

We have a java utility which basically does some business process like validating rules for set of customers. Right now this utility have the limitation that is we cannot run the utility for two customers at the same time(Concurrently) in that case it produces undesired results.

Basically I am thinking how can this be achieved like we can run the same application for different customers concurrently. Again this is simlple Java utility does not have any Enterprise or Webcomponents. When two instances of the same application is run it will still use only one JVM right.What should be kept in mind while designing so that the resources are not shared across two instances of the same application. I am trying to come up with an application which can be run concurrently. Please advise.

Thanks in advance
Bhazee
[ February 24, 2008: Message edited by: Prem Bhazee ]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Bhazee,
How are the apps started? If they are kicked off with a "java" command line, they are already in separate JVMs.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Jeanne

Yes the application is running using java coammdn followed by the jar file. So can you please confirm then everytime this application is run it should create separate JVM' for each instances. So the static variables will also be separate across the JVM's right. Is there anything which will be shared between the different instances of the JVM's for different instances of the application.

I am just trying to understand will any method or variables(static) will be shared across instances of the applicaion.

Thanks in advance
Bhazee
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Yes, every instance is completely separate. No data will be shared.


[Jess in Action][AskingGoodQuestions]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

No data in memory no, but if they read from / write to the same files or databases then you still might want to synchronize.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Prem Bhazee
Ranch Hand

Joined: Feb 18, 2006
Posts: 34
Hi Rob,

When you say no data in memory you mean are you asking whether the different instances will be operating on the same data in memory. Can you please elaborate.

Well they do use and update same database but they are all specific to each customer. For example Customer A updates or works only with its data and Customer B updates or works only with its data.

Thanks
Bhazee
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Originally posted by Prem Bhazee:
When you say no data in memory you mean are you asking whether the different instances will be operating on the same data in memory. Can you please elaborate.

Both static and non-static variables are not shared.

So let's say you have class A, with static field B of some type. Now in the same JVM it is true that any reference to A.B will refer to the same object. However, A.B in one JVM will NOT refer to the same object as A.B in another JVM.

So exactly what both you and Ernest already said.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding running multiple instances of an application
 
Similar Threads
Serializing processing with EJBs
synchronized locker quesion
SQL Exception Connection is busy with results for another hstmt.
Concurrent execution
General Questions on EJB