0% found this document useful (0 votes)
29 views6 pages

VB Multi Threading

Multi-threading allows executing multiple tasks simultaneously by defining each task as a separate thread. The System.Threading namespace provides classes to implement multi-threading in .NET. To create a thread, a Thread object is instantiated passing a method, then the thread is started. Common methods to control threads include Start(), Abort(), Suspend(), Sleep(), and Join(). Synchronization locks can be used to halt other threads until a thread completes its processing.

Uploaded by

Fenil Desai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views6 pages

VB Multi Threading

Multi-threading allows executing multiple tasks simultaneously by defining each task as a separate thread. The System.Threading namespace provides classes to implement multi-threading in .NET. To create a thread, a Thread object is instantiated passing a method, then the thread is started. Common methods to control threads include Start(), Abort(), Suspend(), Sleep(), and Join(). Synchronization locks can be used to halt other threads until a thread completes its processing.

Uploaded by

Fenil Desai
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 6

Multi Threading

• It is used to execute multiple tasks


at a same time where every task
can be defined as a single thread.
• To support this dot net provides a
namespace
“system.threading”
Steps to Implement multi
Threading application
• Step 1  import system.threading
• Step 2 create an object for the thread
class
syntax  modifier threadName as
NewThread(address of method name)
• Step 3provide the definition for the
method which is been binded to the thread
definition.
Note  the definition specified for the
method will be considered as a task that
has to be performed by the thread.
Methods supported for Multi-
Threading
• Start()  used to start the processing of
the thread.
• Abort()  used to kill the processing of
the thread.
• Note  if a thread has been killed
implicitly after completing its processing
or if it has been explicitly killed using
abort method the same thread cant be
restarted again
• Suspend  it is used to halt the
processing of the thread.
Methods supported for
Multi-Threading
• Sleep(milliseconds)  it is a shared
method is used to halt the processing of
the thread for every specific
milliseconds value.
Note  the thread which has been
halted using sleep will be resumed
implicitly
• Join()  if join method is invoked using
a thread then till the processing of that
thread is completed it will halt the
processing of other threads.
Thread Synchronization

Sync lock<>
---
--
end sync lock

• In this both the threads will start together but


when T1 you get sync lock() it will stop the
processing of T2 it will be halted until in T1 is
processed after its done then T1& T2 both will
be resumed to process.
• In this join first the processes of T1 is
completed fully and then T2 will be
resumed.This is done only after T1 is
completed.

You might also like