• 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
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Thread synchronization in J - Scheduler

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using J-Scheduler to schedule a recurring task which basically performs some database queries. I have found a lot of information about how the scheduler handles multi- threading scenarios in case of a single schedule but, I am not sure how my thread will behave in case I have multiple schedules running in parallel and accessing the same database tables and possibly executing the same tasks but with different parameters.

E.g:
Schedule 1 - schedule to run every 1 min and select all the records from Table A and Table B.
Schedule 2 - schedule to run every 4 hrs and select all the records from Table A and Table C.

Now after 4 hrs schedule 1 and schedule 2 will run in parallel. Will I have database consistency or locking problems for table A or is it that even in this case only 1 schedule will execute at a time and the other one will be waiting.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your database should handle its multiple requests on its own. What you would need to do is if one of your requests is writing to a table that another request is reading or writing from, and you need to prevent a race condition, you'd have to use database transactions. If your scheduled tasks are only doing select, with no insert, update, or delete, then you don't need to do anything special.
 
Bras cause cancer. And tiny ads:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic