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

Question: 11

Is there any limitation on the number of daemon threads in an application?

No, there is no limitation on the number of daemon threads in an application.

Question: 12

What is the relationship between a synchronized and volatile keyword?

The JVM is guaranteed to treat reads and writes of data of 32 bits or less as atomic.

For long or double variable, programmers should take care in multithreading environment.

Either put these variables in a synchronized method or block, or declare them volatile.

Question: 13

Can each Java object keep track of all the threads that want to exclusively access to it?

Yes

Question: 14

What are some of the improvements in Concurrency API in java 8?

Some important concurrent API enhancements are

ConcurrentHashMap compute(), forEach(), forEachEntry(), forEachKey(), for EachValue(), merge(), reduce() and search() methods.

CompletableFuture  that may be explicitly completed (setting its value and status).

Executors newWorkStealingPool() method to create a work stealing thread pool using all available processes as its target parallelism level.

Question: 15

What is the use of Join method?

The join method allows one thread to wait for the completion of another. If “t” is a Thread object whose thread is currently executing.

t.join();

Related Questions