I am not sure if this problem has been addressed in any of the previous posts. I have implemented a thread pool manager which creates 5 threads and assigns task to these threads. The thread pool manager waits for all threads to finish and also for all tasks to finish before exiting. The task given to the threads consists of connecting to Oracle database and executing a SQL proc to update records in a table.
If I execute the jar file for this application on a windows based machine, I get the results as expected. However if I run the same jar file on linux platform, the last task is not executed by any of the threads. The behavior of the application is random on linux machine. Sometimes it gives results as expected sometimes it doesn't. Both windows and linux machines have the same JRE installed (1.5).
I am not sure how to debug this issue. Any kind of pointers are most welcomed. Thanks in advance.
Thanks for the reply. I implemented thread pool from scratch. I have given some system.out statements which are printed from the task. No statements are printed from the last task. Also at the end of the program, I am expecting 40,000 records in my table. However only 35,000 records are written into the table since the last task is not executed.
Code snippet from thread pool that assigns task and creates thread if no idle threads are found or waits for one of the threads to finish
Code snippet that waits for all tasks to finish executing
Code snippet from the worker thread which executes the runnable task.