You are on page 1of 7

Micro Project Proposal

“Program of Executing Multithreading”

1.0 Brief introduction


Multithreading is a Java feature that allows concurrent execution of two or more parts of
a program for maximum utilization of CPU. Each part of such a program is called a thread.
So, threads are light-weight processes within a process.

2.0 Aim of the micro project :-


This micro project aims at :
1) To study the Multithreading
2) To study the concept of multithreading

3.0 Action plan

Sr. Details of Planned Planned Name of


No Activates start date finished date Responsible team
member
1 We collected all the 24/4/2021 30/4/2021
information required

2 We studied the 1/5/2021 7/5/2021


collected information

3 We finalized which 8/5/2021 14/5/2021


information will we
required

4 We collected 15/5/2021 21/5/2021


information for creating
multithread

1
3.0 Resource Required :-

Sr. No. Name of Specification Quantity Remark


resource
1. Desktop Windows 7 1
2. JDK - 1
3. MS-Office - 1

4.0 Brief Introduction

1.0 What is multithreading in java


Java is a multi-threaded programming language which means we can develop multi-threaded
program using Java. A multi-threaded program contains two or more parts that can run
concurrently and each part can handle a different task at the same time making optimal use of
the available resources specially when your computer has multiple CPUs.
By definition, multitasking is when multiple processes share common processing resources
such as a CPU. Multi-threading extends the idea of multitasking into applications where you
can subdivide specific operations within a single application into individual threads. Each of
the threads can run in parallel. The OS divides processing time not only among different
applications, but also among each thread within an application.
Multi-threading enables you to write in a way where multiple activities can proceed
concurrently in the same program.

2.0 Life Cycle of a Thread


A thread goes through various stages in its life cycle. For example, a thread is born, started,
runs, and then dies. The following diagram shows the complete life cycle of a thread.

2
Following are the stages of the life cycle –

New − A new thread begins its life cycle in the new state. It remains in this state until
the program starts the thread. It is also referred to as a born thread.

Runnable − After a newly born thread is started, the thread becomes runnable. A
thread in this state is considered to be executing its task.

Waiting − Sometimes, a thread transitions to the waiting state while the thread waits
for another thread to perform a task. A thread transitions back to the runnable state
only when another thread signals the waiting thread to continue executing.

Timed Waiting − A runnable thread can enter the timed waiting state for a
specified interval of time. A thread in this state transitions back to the runnable state
when that time interval expires or when the event it is waiting for occurs.

Terminated (Dead) − A runnable thread enters the terminated state when

3
Advantages of Multithread:

• Improved performance and concurrency


• For certain applications, performance and concurrency can be improved by using
multithreading and multicontexting together. In other applications, performance can be
unaffected or even degraded by using multithreading and multicontexting together.
How performance is affected depends on your application.
• Simplified coding of remote procedure calls and conversations
• In some applications it is easier to code different remote procedure calls and
conversations in separate threads than to manage them from the same thread.
Simultaneous access to multiple applications
• Your BEA Tuxedo clients can be connected to more than one application at a time.
• Reduced number of required servers
• Because one server can dispatch multiple service threads, the number of servers to
start for your application is reduced. This capability for multiple dispatched threads is
especially useful for conversational servers, which otherwise must be dedicated to one
client for the entire duration of a conversation.

Disadvantages of a Multithread:

• Difficulty of writing code

Multithreaded and multicontexted applications are not easy to write. Only


experienced programmers should undertake coding for these types of applications.

• Difficulty of debugging

It is much harder to replicate an error in a multithreaded or multicontexted


application than it is to do so in a single-threaded, single-contexted application. As a
result, it is more difficult, in the former case, to identify and verify root causes when
errors occur.

• Difficulty of managing concurrency

The task of managing concurrency among threads is difficult and has the potential to
introduce new problems into an application.

4
• Difficulty of testing

Testing a multithreaded application is more difficult than testing a single-threaded


application because defects are often timing-related and more difficult to reproduce.

Difficulty of porting existing code

Existing code often requires significant re-architecting to take advantage of


multithreading and multicontexting. Programmers need to:

• Remove static variables o


• Replace any function calls that are not thread-safe
• Replace any other code that is not thread-safe

Because the completed port must be tested and re-tested, the work required to port a
multithreaded and/or multicontexted application is substantial.

Source code :

// Java code for thread creation by extending


// the Thread class
class Multithreading extends Thread {
public void run()
{
try {

// Displaying the thread that is running


System.out.println( "Thread " + Thread.currentThread().getId()
+ " is running");

}
catch (Exception e) {
// Throwing an exception
System.out.println("Exception is caught");
}
}
}

5
// Main Class public class Multithread
{
public static void main(String[] args)
{
int n = 8; // Number of threads
for (int i = 0; i < n; i++)
{
Multithreading object = new
Multithreading();
object.start();
}
}
}

4.0 SKILL DEVELOPED


In this project we learned about the multithreading information and
their types. What is actually in that? Which is that? All of that we studied in brief
report. For this report we collect / Search all the information about multithreading. We
studied the types, advantages, disadvantages of multithreading as well as we studied
the need of multithread and characteristics and forms of multithread

6.0 Course Outcomes Addressed:

a) Select suitable Software Process model for Software development


b) Estimate size and cost of software products.
c) Apply project management and quality assurance principles in software development

6
7.0 RESULT

You might also like