Basic Interview Questions on Multithreading in Java

Saumya Singh
2 min readOct 2, 2019

Q 1 . What is the difference between Processes and Threads ?

Answer .

Process and Thread

Processes are programs that are executing while threads are smallest unit of executable codes .

Processes are isolated from one another while threads share memory or resources with each other .

Q 2 . What are the ways of performing Multithreading in java ?

Answer . Multithreading in java can be performed in two different ways :

1. By extending Thread class .

2. by implementing Runnable Interface .

Q 3. What are the benefits of multi-threaded programming?

Answer . In multiple threading , multiple threads are executed concurrently that helps in improving the performance .

In MultiThreading , CPU is not idle when one thread is waiting for some resources .

Q 4 . Can we call run() method of a Thread class?

Answer . Yes , run() method can be called since it is a method of Thread class . But simply calling run method will make it behave as a normal method . run () method is executed using the start() method i.e Thread.start() .

Q 5 . How can we pause the execution of a Thread for specific time?

Answer . Execution of a Thread can be paused using sleep() method .

Syntax : Thread.sleep(timeMilliSec) .

timeMilliSec is the time in milliseconds for which we want to pause the execution of the thread.

Q 6 . What do you understand about Thread Priority ?

Answer . Thread priorities are numbers that specify relative priority of one thread in comparison to the other thread .

It is used to decide when to switch from one running thread to the other .

A simple program of multithreading in java( explaining each syntax ) is here : https://github.com/SaumyaSingh1/MultiThreading

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Saumya Singh
Saumya Singh

Written by Saumya Singh

GHCI Scholar | International Open Source Award Finalist👩‍🎓 ️| SIH Winner

Responses (1)

Write a response

That’s great Saumya! Congratulations, yes you have accomplished so much and much more to go.
All The Best

--