• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Last task not executed by thread from thread pool

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

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.
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

suvelee sarpotdar wrote:I have implemented a thread pool manager which creates 5 threads and assigns task to these threads.



You mean you have created your own thread pool? OR you are using the thread pool that comes with JDK?

If you have implemented your own, then without seeing the code, it will be very hard to tell anything.

In any case, I will be surprised if its an OS problem.

How, do you determine that the last task is not executed by the pool? Do you dump any statistics?
Is it so that your task is throwing some kind of Error and the thread is getting killed?
 
suvelee sarpotdar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic