I am not a thorough JAVA professional but have experience in Programming, none with threads though. I have an application code which currently does the following.
- Make connection with a DB
- Pull records from DB into a collection (Each record has an 'action code' 1-5 besides other things
- Each record is picked one by one and Based on each action code some particular method (One each for each action code ) is called from a class EVENTHANDLER.class
- These individual methods also use/share some other methodsin EVENTHANDLER.class and some other classes for some common functionality that there is
- Finally the db_sequence is updated
- All records processed so finish
Now , I have a requirement, which is little vague right now, but it wants the introduction of threads into above for primarily a performance enhancement. Along with prioritizing the process of some records with some specific action code above the others. for example- A record with Action code -2 should be on high prority over 1 and then 3 and then 4.
My question is to how to go about first with the approach to implement this. Secondly this is to be done in JAVA 1.6 so what classes should I use. Also any direction codewise (example code) or based on functional flow above would be greatly helpful.
A very direct question is- for the above action code (1-5) should I have five threads running concurrently in whole or should I have one thread for each record (there can be hundreds), irrespective of Action Code?
Thanks Already