jQuery in Action, 3rd edition
The moose likes Threads and Synchronization and the fly likes Thread synchronization in J - Scheduler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread synchronization in J - Scheduler" Watch "Thread synchronization in J - Scheduler" New topic

Thread synchronization in J - Scheduler

Jatin Chanchlani

Joined: Jul 07, 2011
Posts: 2
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.

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

Joined: Jan 03, 2004
Posts: 6109

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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Thread synchronization in J - Scheduler
It's not a secret anymore!