Your SlideShare is downloading. ×
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Thread model of java
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Thread model of java

5,267

Published on

1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total Views
5,267
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
61
Comments
1
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Thread Model of Java
  • 2. Thread model of Java• All the class libraries are designed multithreading in mind• Java uses threads to enable entire system to be asynchronous• Once a thread has been started • It can be suspended • Suspended thread can be resumed • It may be stopped 2
  • 3. Thread model of Java contd..• Thread features • Creation of threads • Context switch • Thread priorities • Synchronization • Messaging 3
  • 4. Creation of Threads• Java provides two ways for creating threads by • Extending Thread class • Implementing Runnable interface 4
  • 5. Context Switch• Switch from one thread to other• Two ways of context switch • Thread can voluntarily relinquish control by • Explicitly yielding • Sleeping • Blocking on pending I/O • Context switch is done by selecting the highest priority thread • Pre-emption • Occurs when a high priority enters while executing a low priority thread 5
  • 6. Thread Priorities• Thread priorities are simple integers • Ranging from 1 to 10 • A relative measure • Higher the priority – brighter the chances of getting executed first 6
  • 7. Synchronization• As threads introduces asynchronous behavior in Java programs • Synchronization is needed when two or more threads work with a shared resource • ‘Monitor’ feature is used in Java to implement Synchronization • Monitors are used mutually exclusive 7
  • 8. Synchronization contd..• There is no special monitor class in Java• Every object has its own implicit monitor• Two ways to show synchronization • synchronized methods • synchronized statements 8
  • 9. Messaging• Java threads communicate with each other through • notify() method • wait() method 9
  • 10. SummaryIn this class ,you have learnt• Thread basics • Process • Definition of thread • Comparison of process and thread • Thread model of Java • Features of Java that implemented threads 10
  • 11. Frequently Asked Questions1. Compare a process and a thread2. Which methods are useful for messaging in Java3. Explain the thread model of Java 11
  • 12. Quiz1. Which one of the following is a thread ? a) MS-Word b) Windows Explorer c) Spell checker in MS-Word d) Notepad 12
  • 13. Quiz Contd..2. Which statement is true? a) Thread does not depend on resources of any process b) Each Thread has its own heap memory c) A Thread share heap with other threads d) None
  • 14. Home Exception Handling Graphical User Interface Programming (GUI)Previous Java question papers with Answers for polytechnic diploma (jntu) OCT/NOV-2012 QUESTION PAPER April / May 2012 c-09 October/ November-2011 c-09 April/ May 2011 c-09 APRIL/MAY-2011 (C-05) Internal Lab question paper External Lab question paper BTECH JNTU LAB MANUAL Lab practice Core java interview questions

×