none
Thread in Threadpool becomes alive after around 30 hrs RRS feed

  • Question

  • The issue is that Threadpool initiates 'n' number of threads to execute its operation.

    One of the thread while executing, goes idle and becomes alive after ~30 hrs. The issue is not happening in the same place.

    Through automation suite, we ran around 720 testcases. For most of the test cases, the application initiaties n number of threads in threadpool. In this one of the thread becomes idle for quite a long time and become alive after ~30 hrs.  This issue is not happening at the same code flow sequence. Sometimes it goes idle at initialization of our components, sometimes while applying some settings etc.,

    The thread is not waiting for any other operation to complete too. 

    We have a timer in the thread which will abort the thread if the time exceeds 2 mins. This timeout is also not occured in the thread. It seems the thread goes idle and not able to find any reason and after almost a day the next line of code being executed.

    Is there any issue with threadpool threads goes idle in between. 

    Thursday, September 19, 2013 5:15 AM

Answers

  • Hi Ganesh,

    This is a strange issue (It seems the thread goes idle and not able to find any reason and after almost a day the next line of code being executed) and I don’t know the details about automation suite. So what we can do is to show you how to debug multithreaded application. See http://msdn.microsoft.com/en-us/library/ms164746.aspx for more information. Please have a look at WinDBG, it also could help you to determine if there is any hang issue on thread.

    Download and Install Debugging Tool: http://msdn.microsoft.com/en-us/windows/hardware/gg463009.aspx

    How to use WinDBG: http://msdn.microsoft.com/en-us/library/windows/hardware/hh406283(v=vs.85).aspx

    Automated .NET Hang Analysis: http://blogs.msdn.com/b/tess/archive/2007/12/12/automated-net-hang-analysis.aspx

    >Sometimes it goes idle at initialization of our components, sometimes while applying some settings etc.

    If the task spends very short time, I recommend you create your own thread and manage it.

    When Not to Use Thread Pool Threads

    In the following scenarios, it is appropriate to create and manage your own threads instead of using thread pool threads:

    • You need to start a number of threads      in a very short time, to execute tasks that last a second or more. As part      of its thread management strategy, the thread pool delays before creating      threads. Therefore, when a number of tasks are queued in a short period of      time, there can be a significant delay before all the tasks are started.
    • You have many tasks that cause the      thread to block for long periods of time. The thread pool has a maximum      number of threads, so a large number of blocked thread pool threads might      prevent tasks from starting.
    • You need to have a stable identity      associated with a thread, or you need to dedicate a thread to a task.

    ----MSDN

    >Is there any issue with thread pool threads goes idle in between. 

    In order to start queued tasks immediately, the thread pool maintains a minimum number of available threads, even when all threads are idle.

    You could find these in http://msdn.microsoft.com/en-us/library/0ka9477y%28v=vs.95%29.aspx.

    The Thread Pool class provides an easy way to take advantage of multiple threads. If you want take control of threads, I think you should write your own thread pool.

    Best Regards,



    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, September 20, 2013 9:09 AM
    Moderator