Sunday, June 7, 2015

Tricky Multithreading and Concurrency Questions from Java Interviews

1) Question on volatile variable

2) Can we make an Array volatile in Java?

3) Can you write code for double checked locking in Singleton?

4) What happens if the object your are synchronizing is null?

5) Why Iterator of ConcurrentHashMap doesn't throw ConcurrentModificationException?

6) What is Busy Spin waiting Strategy? What is benefit?

7) If start() calls run() they why not we call run() method directly?

8) Why you should call wait() and notify() method in loop and not on if block?

Few more questions
- If you are asked to write code for synchronizing between two threads or 100 threads? which code will be harder to write and why?

- Tell me three problems you usually face on concurrent environment.

- What happend if you add task into Fixed thread pool and worker queue is full?

- What happend if an exception is throw into a Thread?

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.