Top 100+ Advanced Multithreading Interview Questions 2019-2020 - 2

Question: 6

What are the uses of synchronized keyword?

The keyword synchronized is used to acquire a exclusive monitor lock on an object. It can be used to mark either a method or a block of code.

In both cases, it means to acquire a lock for the duration of the method, or block and to release the lock at the end.

It also takes a parameter, which names the object, whose lock will be acquired.

Question: 7

How does serialization work?

It’s like FIFO method (first in first out).

Question: 8

How can one thread wait for another thread to die before it continues execution?

The thread’s join() method allows you to wait for another thread to finish execution.

Question: 9

What are the different ways of creating thread?

Implementing Runnable: The Runnable interface defines a single method, run, meant to contain the code executed in the thread.

Subclass Thread: The Thread class itself implements Runnable interface, though it runs method does nothing.

Question: 10

What is Executors class?

Executors class provide utility methods for Executor, ExecutorService, ScheduleExecutorService, ThreadFactory and Collable classes.

Executors class can be used to easily create ThreadPool in java, also this is the only class supporting execution of callable implementations.

Related Questions