I have been a new project for a month.
I have seen a little server program that is designed to multi thread but using timer to repeat jobs. The server basically looking for some records that a flag has been set as 1 and creat one thread per record. Inside the thread, it will modify the flag setting as 0, fetch another record from another table, create a brand new record and so on.
Rough structure of this program is
In my understanding class A is scheduled to be executed every 5000 milisecond. First and foremost, am I right?
I think it is NOT a good design.
I have seen that the main program rescheduled and start to execute before a thread finished. The problem is the most recent rescheduled task interfere the work from thread. The rescheduled task try to fetch same record that is already under work for a thread.
So I modified like this
At first remove class A
Design class B as following
My brand new server didn't accept from the tech leader since the previous one is already running for 3 years.
I think the issue here is I use infinity loop for main program and current server is using Timer for it.
What you guys think? Do you have any valuable link for this?
[ December 12, 2006: Message edited by: Chris Hani ]
[HENRY: Added Code Tags]
[ December 12, 2006: Message edited by: Henry Wong ]