Java Multithreading Interview Questions and Answers

In interviews we usually come across  two topics java collection interview questions and multithreading interview questions. Multithreading is all about concurrency and threads. It is good to be prepared, so do not leave this topic at all.We are sharing important  java multithreading interview questions and answers.

Q1.   What is a thread?

Thread is a lightweight subprocess. Thread class belongs to java.lang package.Threads have their  own stack.It's a way to take advantage of multiple cpu available in a machine. For example, if one thread takes 50 milliseconds to do a job, you can use 10 threads to reduce that task to 5 milliseconds.

Q2 What is the difference between Thread and Process?

A process can have many threads. Threads can execute any part of process.And same part of Process can be executed by multiple threads.

Processes have their own address while Thread share the address space of the process that created it.

Thread has its own stack while in process all threads share a common system resource like heap memory.


Q3 What are the ways to implement Thread in java?

How to sort an ArrayList in Java with Example

In this tutorial we will learn how to sort an ArrayList in java. We will sort the String ArrayList and Integer ArrayList.

Read Also :  How to Reverse ArrayList in Java with Example

1. Program for Sorting String ArrayList

Here we are sorting the ArrayList of String type. We will use the Collections.sort(list) method.  In this case the output list will be sorted alphabetically.

-->