Thursday, 3 August 2017

IMP - How do you ensure that N threads can access N resources without deadlock ?

A very simple way to avoid deadlock while using N threads is to impose an ordering on the locks and force each thread to follow that ordering. Thus, if all threads lock and unlock the mutexes in the same order, no deadlocks can arise.

IMP - Producer Consumer Problem with Wait and Notify Example

IMP - Difference between Callable and Runnable in Java - Interview question

The major difference between Callable and Runnable interface is that Callable can return the result of an operation performed inside call() method, which was one of the limitations with Runnable interface.

The Callable interface can throw checked exception because it's call method throws Exception.

Link One

Generic can allow you to write Template

What is blocking method in future ?

Future provides get() method to get result, which is blocking method and blocks until result is available to Future


Link One

IMP - How you make sure that the task you assigned to a worker thread, has been completed or not ?

we check whether task is completed or not using isDone() method

Link One

Link Two

Why to use anonymous object ?


IMP - Between Executor.submit() and Executer.execute() method ?

Link One

Line Two

How to use Future and FutureTask in Java Concurrency with ...
javarevisited.blogspot.in

Future and FutureTask in Java allows you to write asynchronous code. Future is a general concurrency abstraction, also known as a promise, which promises to return a ...