Академический Документы
Профессиональный Документы
Культура Документы
What is Multi-threading ?
Ans..Net has been designed from the startto support multi-threaded operation.
There are two main ways of multi-threading which .Net encourages:
ThreadStart delegates,
Thread Pool
a. ThreadStart delegates:A delegate is the .Net version of a type safe function
pointer.
All threads require an entry point to start execution.
By definition when a primary thread is created it always runs Main() as it's
entry point.
Any additional threads you create will need an explicitly defined entry point-a
pointer to the function where they begin execution.So threads always require a
delegate.
Delegates are often used in threading for other purposes too,mainly callbacks.
If you want a thread to report some information back such as completion
status,one possibility is to create a callback function that the thread can use.
The releationship between threads and delegates is secondary threads cannot just
call methods like the primary app thread,so a function pointer is needed instead
ans delegates act as a function pointers.
What is a Thread ?
Ans. Thread is the smallest sequence of programmed instructions that can be managed
independently by a scheduler(Program written in OS).
Thread is a component of Process and both are managed and control by OS.
Multiple threads can exist within one process,executing concurrently and
shares resources such as memory,files,etc.
The threads of a process share its instructions and its context.
class GFG {
// Main Method
static public void Main()
{
Thread thr;