From Thread to ThreadPool

  • Thread starter Thread starter Charlie Brown
  • Start date Start date
C

Charlie Brown

What is the better way of doing the following by using the Thread Pool
instead of creating threads?

Dim removalThread As New Threading.Thread(AddressOf
CacheRemovals)
removalThread.Start()

Dim prodThread As New Threading.Thread(AddressOf
CacheProduction)
prodThread.Start()

Dim salesThread As New Threading.Thread(AddressOf CacheSales)
salesThread.Start()

removalThread.Join()
prodThread.Join()
salesThread.Join()

I googled a lot of stuff on thread pools, but frankly there is a lot
of conflicting information on its use.

Thanks in advance,
cb
 
Charlie.

The better thing of doing things is mostly not using threads, it can be fine
to help you to access slow devices.

However, it has only disadvantages as it is by instance used to to cleanoff
caches which are not located on other places then the computer the
mainthread is running on.

Cor
 
Charlie.

The better thing of doing things is mostly not using threads, it can be fine
to help you to access slow devices.

However, it has only disadvantages as it is by instance used to to cleanoff
caches which are not located on other places then the computer the
mainthread is running on.

Cor












- Show quoted text -

Thanks for your input,
Each of the methods called takes a long time to execute, so calling
them async will save the user from having to wait a long period of
time. If each of the three methods takes 15 seconds to complete,
calling them sync will take about 45 seconds, calling them async will
take little more that 15 seconds, so the advantages to the user are
pretty clear.
 
Thanks for your input,
Each of the methods called takes a long time to execute, so calling
them async will save the user from having to wait a long period of
time.  If each of the three methods takes 15 seconds to complete,
calling them sync will take about 45 seconds, calling them async will
take little more that 15 seconds, so the advantages to the user are
pretty clear.- Hide quoted text -

- Show quoted text -

Can anyone offer any advice on using threads a better way? i
understand that creating threads from scratch is much more expensive
than using the threadpool.
 
Charlie,

What is better, to write, performance, maintainability, tolerancy?

Be aware that there is since version 2005 the backgroundworker class

http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

Cor


Thanks for your input,
Each of the methods called takes a long time to execute, so calling
them async will save the user from having to wait a long period of
time. If each of the three methods takes 15 seconds to complete,
calling them sync will take about 45 seconds, calling them async will
take little more that 15 seconds, so the advantages to the user are
pretty clear.- Hide quoted text -

- Show quoted text -

Can anyone offer any advice on using threads a better way? i
understand that creating threads from scratch is much more expensive
than using the threadpool.
 
Good point. Although the code really doesn't get called that often,
and I really don't care about performance that much, I was really just
wondering how to do it. I have read that using thread pools is
better, but again, there is a lot of conflicting information about
multithreading out there.
 
I am not sure what your question means.

I have used the backgroundworker class, and in some scenarios it works
great. I am really just looking for "how" to do the same thing with
the thread pool.
 
Back
Top