Seminar Topics & Project Ideas On Computer Science Electronics Electrical Mechanical Engineering Civil MBA Medicine Nursing Science Physics Mathematics Chemistry ppt pdf doc presentation downloads and Abstract

Full Version: Thread Programming in Java
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[attachment=72720]


Thread
“Thread is a lightweight process.”

Process : “Program in execution”
A processor executes threads, not processes.
So each application has at least one process, and a process always has at least one thread of execution, known as the primary thread.
We can create or assign more than one thread for a single process.
Multithreading : ”It is the ability of an operating system to execute different parts of a program, i.e. threads, on a single processor concurrently.”
It enables maximum use of the CPU, because idle time can be kept to a minimum.
A multithreading is a specialized form of multitasking.
Example: Word Document

Thread life cycle
Creating a Thread
Java defines two ways in which this can be accomplished:
Implement the Runnable interface
Extend the Thread class, itself.

Program:1
Write an application that executes two threads. One thread display “Hello world” every 2000 milliseconds and another thread display “How are you?” every 1000 milliseconds. Create the threads by implementing Runnable interface.