-
October 19th, 2010, 11:52 PM
#1
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
-
October 20th, 2010, 01:40 AM
#2
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...
-
October 20th, 2010, 06:01 AM
#3
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.
-
October 20th, 2010, 07:36 AM
#4
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.
-
October 20th, 2010, 02:04 PM
#5
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.
-
October 20th, 2010, 11:10 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|