Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread synchronization in J - Scheduler  RSS feed

 
Jatin Chanchlani
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!