• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Thread model of java
 

Thread model of java

on

  • 4,001 views

 

Statistics

Views

Total Views
4,001
Views on SlideShare
3,990
Embed Views
11

Actions

Likes
0
Downloads
34
Comments
1

1 Embed 11

http://improvejava.blogspot.in 11

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Thread model of java Thread model of java Presentation Transcript

    • Thread Model of Java
    • 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
    • Thread model of Java contd..• Thread features • Creation of threads • Context switch • Thread priorities • Synchronization • Messaging 3
    • Creation of Threads• Java provides two ways for creating threads by • Extending Thread class • Implementing Runnable interface 4
    • 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
    • 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
    • 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
    • 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
    • Messaging• Java threads communicate with each other through • notify() method • wait() method 9
    • 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
    • Frequently Asked Questions1. Compare a process and a thread2. Which methods are useful for messaging in Java3. Explain the thread model of Java 11
    • Quiz1. Which one of the following is a thread ? a) MS-Word b) Windows Explorer c) Spell checker in MS-Word d) Notepad 12
    • 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
    • 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