• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

env variable or so

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there,
i have 2 java applications and one needs to check if the other is still running by setting a variable and wait, so in the meantime the other application can change the value of the same variable, so to prove that it is still running. each application has a thread doing this checking.
any idea what mechanism i can use for storing this variable ? is there something like a env.variable i can use ? ore properties stored outside the java applications ? i would prefer not to use a file....

thx
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One standard way for processes to communicate is through sockets.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are both the apps running in the same JVM? Is so, you could use a third entity, like a Singleton to hold the variable. If they are running in different JVMs, you have to resort to something that they both can access - like a file.

Here's another thought - instead of applications querying for the "state", why not use a Mediator - something that tells each interested app that the state has changed? Since I don't know the details of your apps, I cannot fathom whether this strategy translates to an over-engineered solution.
reply
    Bookmark Topic Watch Topic
  • New Topic