This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding running multiple instances of an application

 
Prem Bhazee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34973
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bhazee,
How are the apps started? If they are kicked off with a "java" command line, they are already in separate JVMs.
 
Prem Bhazee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, every instance is completely separate. No data will be shared.
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No data in memory no, but if they read from / write to the same files or databases then you still might want to synchronize.
 
Prem Bhazee
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic