What is the difference between multitasking and multithreading? What is the difference between the Abort, Suspend and Sleep methods of the Thread class?
Copyright © 2008 Department of Education - Introduction to Visual Basic – VB.Net Page 324
1. What is the difference between multitasking and multithreading?
Multitasking is the process of sharing system resources among different applications processes, while multithreading is the process of sharing system resources among
different threads execution unit within an application. In multitasking, different processes share the processors time while in multithreading, different threads share the processor
time allotted to their parents process. 2. What is the difference between a process and a thread?
A process is an independently executing application. A thread is an execution unit within a process. A process may have multiple threads. All the threads in a process work for that
process. A thread does not have separate memory space and other resources but shares the memory space and resources allotted to the parent process. Inter-thread communication is
relatively a lot easier and common than the Inter-process communication. 3. Why and when should one use multiple threads multi-threading instead of
multitasking? When you need to perform different tasks closely related to your application that use
objects and resources held by your process and which are closely related to the core logic of your application; you should go for multithreading. On the contrary, when you need to
perform multiple tasks independent of each other simultaneously, you should go for multitasking.
4. What is the difference between the Abort, Suspend and Sleep methods of the Thread class?
The Abort method permanently terminates the execution of the thread. The Suspend method pauses the execution of the thread until the Resume method is called. The Sleep
method pauses the running of the thread for a specified amount of time. 5. Why is the ThreadAbortException thrown in the thread method when the
Abort method is called for that thread? Is it an error to call the Abort method? No, not at all, aborting the thread is not an error. The Abort method throws the
ThreadAbortException just to inform the executing thread that it is being asked to terminate and it should start performing the clean up code so that it may be terminated safely. The
Abort method is extremely useful when you provide your user with the option to Cancel the current activity. For example, you are searching for some text in a file in a thread and
the user presses the Cancel button to stop searching. In this case, the Abort method of the thread is called which throws the ThreadAbortException in the search method, which
closes the file connection and gets terminated.
Copyright © 2008 Department of Education - Introduction to Visual Basic – VB.Net Page 325
6. What are the advantages and disadvantages of accessing shared objects with multiple threads?