This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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.
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.