<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>
<b>Session 1</b>
</div>
<span class='text_page_counter'>(2)</span><div class='page_container' data-page=2>
Advanced Java / Session1 / 2 of 13
Module 1
Introduction to Thread
2
A Guide To Advanced Java – Module 1
</div>
<span class='text_page_counter'>(3)</span><div class='page_container' data-page=3></div>
<span class='text_page_counter'>(4)</span><div class='page_container' data-page=4>
Advanced Java / Session1 / 4 of 13
</div>
<span class='text_page_counter'>(5)</span><div class='page_container' data-page=5>
<b>Creating Threads</b>
Sub classing Thread
Creating subclass
Overriding the run()
method
Starting the thread
Using the Runnable
interface
Implementing the
Runnable interface
Implementing the run()
method
</div>
<span class='text_page_counter'>(6)</span><div class='page_container' data-page=6>
Advanced Java / Session1 / 6 of 13
<b>Thread states</b>
</div>
<span class='text_page_counter'>(7)</span><div class='page_container' data-page=7>
<b>Methods of the Thread class</b>
The getName() method helps to retrieve the name
of the current thread
The setName() method assigns a name to a thread
The start() method allocates the system resources
necessary to run the thread and executes the run()
method of its target object
The run() method contains instructions, which are
</div>
<span class='text_page_counter'>(8)</span><div class='page_container' data-page=8>
Advanced Java / Session1 / 8 of 13
<b>Methods of the Thread class …</b>
</div>
<span class='text_page_counter'>(9)</span><div class='page_container' data-page=9></div>
<span class='text_page_counter'>(10)</span><div class='page_container' data-page=10>
Advanced Java / Session1 / 10 of 13
<b>Managing Thread</b>
Thread priority
Thread.MAX_PRIORITY : constant value of 10
Thread.NORM_PRIORITY : constant value of 5, default
Thread.MIN_PRIORITY : constant value of 1
Methods:
setPriority()
getPriority()
A Guide To Advanced Java – Module 1 10
•
<sub>Thread priority helps the thread scheduler to decide </sub>
which thread to run
•
<sub>Priority also helps the OS to decide the amount of </sub>
</div>
<span class='text_page_counter'>(11)</span><div class='page_container' data-page=11></div>
<span class='text_page_counter'>(12)</span><div class='page_container' data-page=12>
Advanced Java / Session1 / 12 of 13
<b>Needs for Daemon Thread</b>
</div>
<span class='text_page_counter'>(13)</span><div class='page_container' data-page=13></div>
<!--links-->