CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    what is maximum num of threads use in application?

    Hi all,

    please tell me what is the maximum number of threads that i use in my SDI type application.

    its is safe to generate and handle this large number of threads in application,or there is any othre option to handle this.

    i have an ListCtrl and this have hundred of items,i want to check all item at same time so i generate thread for each item, but some time there is execption occur when start or stop the thread.

    please help me for this.

    thanks in advance.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

  2. #2
    Join Date
    May 2009
    Location
    Bengaluru, India
    Posts
    460

    Re: what is maximum num of threads use in application?

    there will be some limitation for number of threads you can create, but stil there should be some APIs dealing with low level OS for manipulating the thread details...

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: what is maximum num of threads use in application?

    I don't know about the theoretical limitations, but practical limitations will be a few threads for each core. Otherwise the context switching between the threads will overcome the benefit of running concurrent. Having hundreds of threads is definitely not efficient. You should stick to several. However, processing just some hundreds of items should not be a problem even with a single thread, unless you spend some considerable time for each item.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: what is maximum num of threads use in application?

    its is safe to generate and handle this large number of threads in application
    The question is, do you really need many threads ? If I look at your last topics, I think you are going at it the wrong way.

  5. #5
    Join Date
    Nov 2007
    Posts
    35

    Re: what is maximum num of threads use in application?

    Instead of creating a thread to handle each job in the list you may want to consider having the UI thread as the "producer" and a worker thread as the "consumer". In this scenario the UI thread gets the info from the list control and uses something such as Concurrent_queue to put the job on the job list. That takes very little time and leaves the UI thread responsive to user input. The worker thread "consumes" jobs from the queue and does whatever. If it's a long computation you may want to have some feedback to show the user the stuff is being worked such as the number of jobs in the status bar or whatever.

    Trying to launch too many threads and keep track of what's going on will likely just make the app crash prone. Better to get the job done reliably first, then enhance speed later once you understand all the implications.

  6. #6
    Join Date
    Jan 2008
    Location
    India
    Posts
    780

    Re: what is maximum num of threads use in application?

    can u please explain it with example or provide me any sample example.

    please help me for this.

    i really need it.
    IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured