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
“[Link]”
Steps to Implement multi
Threading application
• Step 1 import [Link]
• Step 2 create an object for the thread
class
syntax modifier threadName as
NewThread(address of method name)
• Step 3provide 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
[Link] is done only after T1 is
completed.