0% found this document useful (0 votes)
4 views4 pages

Java Multithreading: Creating Threads

Multithreading in Java enables concurrent execution of multiple parts of a program, referred to as threads, which are lightweight processes. Threads can be created by either extending the Thread class or implementing the Runnable interface, both of which involve overriding the run() method. To start execution, the start() method is called on the thread object.

Uploaded by

ps7207295
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Java Multithreading: Creating Threads

Multithreading in Java enables concurrent execution of multiple parts of a program, referred to as threads, which are lightweight processes. Threads can be created by either extending the Thread class or implementing the Runnable interface, both of which involve overriding the run() method. To start execution, the start() method is called on the thread object.

Uploaded by

ps7207295
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Threads

● 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 program is called a thread. So,
threads are light-weight processes within a
process.
● Threads can be created by using two
mechanisms :
● Extending the Thread class
● Implementing the Runnable Interface
● Thread creation by extending the Thread class
● We create a class that extends the
[Link] class. This class overrides the
run() method available in the Thread class. A
thread begins its life inside run() method. We
create an object of our new class and call start()
method to start the execution of a thread.
Start() invokes the run() method on the Thread
object
● Thread creation by implementing the Runnable
Interface
● We create a new class which implements
[Link] interface and override run()
method. Then we instantiate a Thread object
and call start() method on this object.

You might also like