Solved

Single Vs MultiThreading 2

Posted on 2002-04-03
9
152 Views
Last Modified: 2010-05-02
Is there any advantage to multi-threading if you are not using ASynchronous programming techniques?
0
Comment
Question by:Lisp
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 2

Expert Comment

by:ronenr
ID: 6917423
Usually multi-threding is for performing several tasks at the "same time" or for balancing the work between several processors. If you have a tasks that must be sequencially I thing that multithreding will not give any advantage. In the other hand it will make the computer to work more, because now it has to maintaine 2 proccesses instead of one.

Hope it helps
0
 

Author Comment

by:Lisp
ID: 6917613
Wait a minute.  I'm not talking about using out of process components where you would have multiple processes.  I'm talking about using a single process, using many in-process add-ins.  Using a single process with multiple threads.
0
 
LVL 2

Expert Comment

by:ronenr
ID: 6917653
When you use multi-threading each thread is a separate process, you can call them lite processes, but they are independent proccesses they have their our process id you can give them priority, etc. But they do differ from out-proccess in many way, one the differences are the memory segment they use.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6917706
which version of VB are you using? if you are using VB6, be advised that there are no easy ways of doing multithread. VB.Net gives you the trhread object.

>>Is there any advantage to multi-threading

The classical example if the print option of Word is done in a separate thread to allow you to continue to work while the document is printed.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 18

Expert Comment

by:mdougan
ID: 6918619
Another classical example is to use Multi-threading in Server type components.  So, if you have a Search Index component, and you want to allow multiple clients to search at the same time, without having each one run an instance of the conponent, or each request having to queue until the component is available, you can have one instance that farms each request out to a separate thread where the requests can process in parallel.

This also leads to resource "pooling", so, you might have a thread pool, where threads are already allocated, storage is already loaded, but the threads are idle.  Then, when a new request comes along, it's queued until there is an available thread, and then it gets to run, but this will be much faster than if threads have to be created and resources allocated for each request.

It is possible for threads to be used in a process that might be more or less sequential, but have certain components that can be multi-threaded.  Take the search index as an example.  Maybe one request comes in, you single-thread at first, maybe parse the search string, find that there are 5 search terms, then create 5 threads, send each search term to the search index component, and then wait for notification that all 5 threads have finished processing (using either callbacks or there is something called semaphores and mutexes) then single thread again to display the results to the user.  This would simply have the effect of speeding up the search by running it in parallel.  Many database management system already employ such techniques when running large queries.

As was already stated, it's also possible to assign different priorities to the threads.  Normally, the main process has a pretty high priority, but it's possible to bump a thread to a higher priority, and it will get more processor, and/or you can bump a thread to a lower priority if you want something to happen in the background, but not negatively affect the foreground process.
0
 

Author Comment

by:Lisp
ID: 6920036
I thought that multi-threading was as simple as choosing Apartment threading over single threading.  I know that its not ultra specific but is that not multiple threading? Yes I am using VB6.
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 100 total points
ID: 6920526
Apartment thread is only there to be used when building MTS (or COM+) component. MTS requires a component to be compiled as apartment to be able to fully work correctly with MTS rules.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6920532
You don't have any object from within VB to declare a thread, pass parameters to it, start it, synchronize it, abort it... This is the proof that mutli-threading is not implemented intrinsicly.
0
 
LVL 18

Expert Comment

by:mdougan
ID: 6921941
My understanding of "Apartment Threading" is that it is a euphamism for improved single-threading, the way "multi-tasking" was a euphamism for time-slicing under Windows 3X.

The concept was that you might have many people actively living in an apartment building, but only one can use the front door at any one time.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now