• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread synchornization across multiple application servers

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am wirting a poller application which will be deployed on WAS.
This poller application will be deployed on two AIX servers.
It is basically polling a oracle database and reading records. The polling is being done by a thread which is created in the application.
The number of threads to be started is configurable. As long as this application runs in a single server, there are no issues with the thread synchorization.
How can we achieve synchronization when the same application is running on two different AIX servers and accessing the same database?


Regards,
Anup
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Synchronization across two JVMs can not be done only via the synchronized keyword.
The simplest way is to have a lock table in the database.
Before starting the process, any thread can check the status in the lock table. This status can just be a boolean flag. If nobody is working on the polling then the flag can be true.
Whenever, a thread starts polling, it will set the flag to false.
So, at any moment only one thread will be polling the DB.


Moving to Threads & Synchronization forum.
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just so that I also understand it properly, all I am doing is adding an extra where clause in my lookup query to filter any records with flag 'false' (or 'true' depending on the situation)?

thanks,
tualha
 
reply
    Bookmark Topic Watch Topic
  • New Topic