SlideShare ist ein Scribd-Unternehmen logo
1 von 10
MULTITHREADING
Definition 
Threading: A thread is an independent execution path, able to run 
simultaneously with other threads. 
Multithreading: Multithreading is used to perform multiple tasks at the 
same time.
Thread life cycle
Creation 
• C# supports 2 methods to create threads 
 Using the Thread class. 
 Using the Thread pool. 
Thread Class: 
 A new thread object is created and a delegate is passed to the thread’s constructor. 
Thread Pool: 
 C# provides a pool of threads. Tasks can be assigned to the threads in the pool.
Thread Class: 
Thread thread1 = new Thread(new ThreadStart(Thread1)); 
Thread thread2 = new Thread(new ThreadStart(Thread2)); 
//thread2.Priority = ThreadPriority.Highest; 
thread1.Name = "First"; 
thread2.Name = "Second"; 
thread1.Start(); 
thread2.Start();
Synchronization: 
lock (this) 
{ 
for(int i=0;i<5;i++) 
Console.WriteLine(“Current thread is {0} and value of i is {1} ”,Thread.CurrentThread.Name,i); 
}
Thread Communication:
Wait() Method: 
Releases the lock on an object and blocks the current thread until it reacquires 
the lock. 
Syntax: Monitor.Wait(object); 
Pulse() Method: 
Notifies a thread in the waiting queue of a change in the locked object's state. 
Syntax: Monior.Pulse(object);
Deadlock: 
 A deadlock is a situation where an application locks up because two or more activities are 
waiting for each other to finish. 
lock(lock1) 
{ 
lock(lock2) 
{…} 
}

Weitere ähnliche Inhalte

Was ist angesagt?

Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
parag
 
Multithreading
MultithreadingMultithreading
Multithreading
sagsharma
 

Was ist angesagt? (20)

Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Multithreading In Java
Multithreading In JavaMultithreading In Java
Multithreading In Java
 
Multithreading
MultithreadingMultithreading
Multithreading
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Threads (operating System)
Threads (operating System)Threads (operating System)
Threads (operating System)
 
Life cycle-of-a-thread
Life cycle-of-a-threadLife cycle-of-a-thread
Life cycle-of-a-thread
 
Thread
ThreadThread
Thread
 
Chap2 2 1
Chap2 2 1Chap2 2 1
Chap2 2 1
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
Data types
Data typesData types
Data types
 
Polymorphism in java
Polymorphism in javaPolymorphism in java
Polymorphism in java
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Type casting
Type castingType casting
Type casting
 
While , For , Do-While Loop
While , For , Do-While LoopWhile , For , Do-While Loop
While , For , Do-While Loop
 
WHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVAWHAT IS ABSTRACTION IN JAVA
WHAT IS ABSTRACTION IN JAVA
 
Nested loops
Nested loopsNested loops
Nested loops
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
 
Exception handling
Exception handlingException handling
Exception handling
 

Andere mochten auch

Usecase diagram railway reservation system
Usecase diagram railway reservation systemUsecase diagram railway reservation system
Usecase diagram railway reservation system
muthumeenakshim
 
Requirements elicitation
Requirements elicitationRequirements elicitation
Requirements elicitation
Abdul Basit
 

Andere mochten auch (17)

Bill Gates
Bill GatesBill Gates
Bill Gates
 
use case diagramHospital managment system
use case diagramHospital managment systemuse case diagramHospital managment system
use case diagramHospital managment system
 
Usecase diagram railway reservation system
Usecase diagram railway reservation systemUsecase diagram railway reservation system
Usecase diagram railway reservation system
 
Generics collections
Generics collectionsGenerics collections
Generics collections
 
collections
 collections collections
collections
 
C#4.0 features
C#4.0 featuresC#4.0 features
C#4.0 features
 
Requirements elicitation
Requirements elicitationRequirements elicitation
Requirements elicitation
 
exception handling
 exception handling exception handling
exception handling
 
business analyst interview questions and answers
business analyst interview questions and answersbusiness analyst interview questions and answers
business analyst interview questions and answers
 
Use of ict tools for teaching –learning
Use of ict tools for teaching –learningUse of ict tools for teaching –learning
Use of ict tools for teaching –learning
 
Business analyst interview questions and answers
Business analyst interview questions and answersBusiness analyst interview questions and answers
Business analyst interview questions and answers
 
Use Case Modeling
Use Case ModelingUse Case Modeling
Use Case Modeling
 
Business Analysis Fundamentals
Business Analysis FundamentalsBusiness Analysis Fundamentals
Business Analysis Fundamentals
 
Business Analyst Training
Business  Analyst  TrainingBusiness  Analyst  Training
Business Analyst Training
 
Business analyst ppt
Business analyst pptBusiness analyst ppt
Business analyst ppt
 
Business analysis interview question and answers
Business analysis interview question and answersBusiness analysis interview question and answers
Business analysis interview question and answers
 
85 business analyst interview questions and answers
85 business analyst interview questions and answers85 business analyst interview questions and answers
85 business analyst interview questions and answers
 

Ähnlich wie multi threading

Python multithreading session 9 - shanmugam
Python multithreading session 9 - shanmugamPython multithreading session 9 - shanmugam
Python multithreading session 9 - shanmugam
Navaneethan Naveen
 
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
nimbalkarvikram966
 
Multithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming languageMultithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming language
arnavytstudio2814
 
Java class 6
Java class 6Java class 6
Java class 6
Edureka!
 
OOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptxOOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptx
Arulmozhivarman8
 

Ähnlich wie multi threading (20)

Python multithreading session 9 - shanmugam
Python multithreading session 9 - shanmugamPython multithreading session 9 - shanmugam
Python multithreading session 9 - shanmugam
 
Class notes(week 9) on multithreading
Class notes(week 9) on multithreadingClass notes(week 9) on multithreading
Class notes(week 9) on multithreading
 
Class notes(week 9) on multithreading
Class notes(week 9) on multithreadingClass notes(week 9) on multithreading
Class notes(week 9) on multithreading
 
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
07. Parbdhdjdjdjsjsjdjjdjdjjkdkkdkdkt.pptx
 
Multithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming languageMultithreading in Java Object Oriented Programming language
Multithreading in Java Object Oriented Programming language
 
BCA MultiThreading.ppt
BCA MultiThreading.pptBCA MultiThreading.ppt
BCA MultiThreading.ppt
 
Java class 6
Java class 6Java class 6
Java class 6
 
Python programming : Threads
Python programming : ThreadsPython programming : Threads
Python programming : Threads
 
Java unit 12
Java unit 12Java unit 12
Java unit 12
 
java-thread
java-threadjava-thread
java-thread
 
Python multithreading
Python multithreadingPython multithreading
Python multithreading
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
multithreading, creating a thread and life cycle in java.ppt
multithreading, creating a thread and life cycle in java.pptmultithreading, creating a thread and life cycle in java.ppt
multithreading, creating a thread and life cycle in java.ppt
 
Multithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of threadMultithreading Introduction and Lifecyle of thread
Multithreading Introduction and Lifecyle of thread
 
MULTI THREADING.pptx
MULTI THREADING.pptxMULTI THREADING.pptx
MULTI THREADING.pptx
 
OOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptxOOPS object oriented programming UNIT-4.pptx
OOPS object oriented programming UNIT-4.pptx
 
Threading
ThreadingThreading
Threading
 
javathreads
javathreadsjavathreads
javathreads
 
Thread model in java
Thread model in javaThread model in java
Thread model in java
 
U4 JAVA.pptx
U4 JAVA.pptxU4 JAVA.pptx
U4 JAVA.pptx
 

Mehr von Yaswanth Babu Gummadivelli

Mehr von Yaswanth Babu Gummadivelli (20)

Presentation on BA
Presentation on BAPresentation on BA
Presentation on BA
 
ERP
ERPERP
ERP
 
Ba -content
Ba -contentBa -content
Ba -content
 
E commerce use case documentation.
E commerce use case documentation.E commerce use case documentation.
E commerce use case documentation.
 
MOM on activity diagram
MOM on activity diagramMOM on activity diagram
MOM on activity diagram
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
MOM on BA
MOM on BAMOM on BA
MOM on BA
 
Constructors
Constructors Constructors
Constructors
 
array
array array
array
 
Use case for atm
Use case for atmUse case for atm
Use case for atm
 
Activity diagram for ticket vending machine
Activity diagram for ticket vending machineActivity diagram for ticket vending machine
Activity diagram for ticket vending machine
 
Extreme programming
Extreme programmingExtreme programming
Extreme programming
 
Agile model
Agile model Agile model
Agile model
 
Business Analyst
Business AnalystBusiness Analyst
Business Analyst
 
CRM and ERP
CRM and ERPCRM and ERP
CRM and ERP
 
Reflection
ReflectionReflection
Reflection
 
Exceptions in SQL Server
Exceptions in SQL ServerExceptions in SQL Server
Exceptions in SQL Server
 
Views
ViewsViews
Views
 
Triggers
TriggersTriggers
Triggers
 
Subqueries
SubqueriesSubqueries
Subqueries
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...Navigating the Misinformation Minefield: The Role of Higher Education in the ...
Navigating the Misinformation Minefield: The Role of Higher Education in the ...
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 
The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdf
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptxREPRODUCTIVE TOXICITY  STUDIE OF MALE AND FEMALEpptx
REPRODUCTIVE TOXICITY STUDIE OF MALE AND FEMALEpptx
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
size separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceuticssize separation d pharm 1st year pharmaceutics
size separation d pharm 1st year pharmaceutics
 

multi threading

  • 2. Definition Threading: A thread is an independent execution path, able to run simultaneously with other threads. Multithreading: Multithreading is used to perform multiple tasks at the same time.
  • 4. Creation • C# supports 2 methods to create threads  Using the Thread class.  Using the Thread pool. Thread Class:  A new thread object is created and a delegate is passed to the thread’s constructor. Thread Pool:  C# provides a pool of threads. Tasks can be assigned to the threads in the pool.
  • 5. Thread Class: Thread thread1 = new Thread(new ThreadStart(Thread1)); Thread thread2 = new Thread(new ThreadStart(Thread2)); //thread2.Priority = ThreadPriority.Highest; thread1.Name = "First"; thread2.Name = "Second"; thread1.Start(); thread2.Start();
  • 6.
  • 7. Synchronization: lock (this) { for(int i=0;i<5;i++) Console.WriteLine(“Current thread is {0} and value of i is {1} ”,Thread.CurrentThread.Name,i); }
  • 9. Wait() Method: Releases the lock on an object and blocks the current thread until it reacquires the lock. Syntax: Monitor.Wait(object); Pulse() Method: Notifies a thread in the waiting queue of a change in the locked object's state. Syntax: Monior.Pulse(object);
  • 10. Deadlock:  A deadlock is a situation where an application locks up because two or more activities are waiting for each other to finish. lock(lock1) { lock(lock2) {…} }