Blog Posts - Java Multithreading Tutorials



5 Essential difference between Callable and Runnable interface in Java?

The difference between Callable and Runnable is one of the most frequently asked multi-threading and concurrency interview question in Java world. I remember, it was 2007 when I first heard about Callable interface and that too on a telephonic interv...
by javarevisited on Aug 20, 2016

Top 5 Books to Learn Concurrent Programming and Multithreading in Java - Best, Must Read

Books are very important to learn something new and despite being in the electronic age, where books have lost some shine to internet and blogs, I still read and recommend them to get a complete and authoritative knowledge on any topic e.g. concurren...
by javarevisited on Jun 15, 2016

Difference between ExecutorService.submit() and Executor.execute() methods in Java?

What is the difference between Executor.submit() and Executor.execute() method in Java? is one of the good multi-threading questions for experienced Java programmers, mostly asked in Investment Banks like Barclays, Deutsche Bank, or Citibank. A main...
by javarevisited on Apr 19, 2016

Difference between Wait and Sleep, Yield in Java

The difference between wait and sleep or the difference between sleep and yield in Java are one of the popular core Java interview questions and asked on multi-threading interviews. Out of three methods which can be used to pause a thread in Java, sl...
by javarevisited on Mar 25, 2016

Java Synchronization Tutorial : What, How and Why?

Multithreading and synchronization are a very important topic for any Java programmer. Good knowledge of multithreading, synchronization, and thread-safety can put you in front of other developers, at the same time, it's not easy to master this c...
by javarevisited on Mar 17, 2016

Top 50 Java Thread Interview Questions Answers for Experienced

You go to any Java interview, senior or junior, experience or freshers,  you are bound to see a couple of questions from the thread, concurrency, and multi-threading. In fact, this built-in concurrency support is one of the strongest points of Java...
by javarevisited on Mar 9, 2016

How to use wait, notify and notifyAll in Java - Producer Consumer Example

You can use wait, notify and notifyAll methods to communicate between threads in Java. For example, if you have two threads running in your program e.g.Producer and Consumer then producer thread can communicate to consumer that it can start consuming...
by javarevisited on Jul 1, 2015

Top 10 Java Multithreading and Concurrency Best Practices

Writing concurrent code is hard and and testing correctness with concurrency is even harder. Though Java programming language provides lots of synchronization and concurrency support from language to API level, it's eventually comes to individual...
by javarevisited on May 27, 2015

How to use Future and FutureTask in Java Concurrency with Example

Future and FutureTask in Java allows you to write asynchronous code. Future is a general concurrency abstraction, also known as promise, which promises to return a result in future. In asynchronous programming, main thread doesn't wait for any ta...
by javarevisited on Jan 27, 2015

How to Use Locks in Multi-threaded Java Program

Many Java programmers confused themselves like hell while writing multi-threaded Java programs e.g. where to synchronized? Which Lock to use? What Lock to use etc. I often receive request to explain about how to use Locks in Java, so I thought to wri...
by javarevisited on Oct 14, 2014

Common Multi-threading Mistakes in Java - Calling run() instead of start()

Writing multi-threaded and concurrent programs is not easy, not even in Java.  Even senior developers, including myself, make mistakes while writing concurrent Java applications. This is also one of the trickiest area of Java programming language, w...
by javarevisited on Sep 22, 2014

Top 50 Java Thread Interview Questions Answers for Freshers, Experienced Programmers

You go to any Java interview, senior or junior, experience or freshers,  you are bound to see couple of questions from thread, concurrency and multi-threading. In fact this built-in concurrency support is one of the strongest point of Java programmi...
by javarevisited on Jul 2, 2014

SynchronousQueue Example in Java - Produer Consumer Solution

SynchronousQueue is special kind of BlockingQueue in which each insert operation must wait for a corresponding remove operation by another thread, and vice versa. When you call put() method on SynchronousQueue it blocks until another thread is there...
by javarevisited on Jun 9, 2014

Inter Thread Communication in Java using Wait Notify Example

Wait and notify methods in Java are used for inter-thread communication i.e. if one thread wants to tell something to another thread, it uses notify() and notifyAll() method of java.lang.Object. Classical example of wait and notify method is Producer...
by javarevisited on Dec 30, 2013

How to create Thread Pools using Java 1.5 Executor Framework - Example Tutorial

Java 1.5 introduced Thread pool in Java in form of Executor framework, which allows Java programmer to decouple submission of task to execution of task. If you are doing server side programming in Java than Thread pool is an important concept to main...
by javarevisited on Jul 23, 2013

How to create Thread Pools using Java 5 Executor Framework - Example Tutorial

Java 5 introduced Thread pool in Java in form of Executor framework, which allows Java programmer to decouple submission of task to execution of task. If you are doing server side programming in Java than Thread pool is an important concept to mainta...
by javarevisited on Jul 23, 2013

ReentrantLock Example in Java, Difference between synchronized vs ReentrantLock

ReentrantLock in Java is added on java.util.concurrent package in Java 1.5 along with other concurrent utilities like CountDownLatch, Executors and CyclicBarrier. ReentrantLock is one of the most useful addition in Java concurrency package and severa...
by javarevisited on Mar 7, 2013

How to Join Multiple Threads in Java - Thread Join Example

Join method from Thread class is an important method and used to impose order on execution of multiple Threads. Concept of joining multiple threads is very popular on  mutithreading interview question. Here is one of such question, “You have three...
by javarevisited on Feb 6, 2013


Trending Topics

Close