Code Pumpkin

Tag Archives: Multithreading

Morgan Stanley Interview Questions – Set 1

August 26, 2017
Posted by Rahul Jain

Recently I have appeared for Java developer interview at the Morgan Stanley, Mumbai. It was a Video conference interview. Here are the set of questions asked to me :   Tell me about your current project and your roles and responsibility. Write a java function to reverse a string using recursion Write a java program […]

Threadpool using Executor Framework | Java Concurrency Utilities

June 30, 2017
Posted by Abhi Andhariya

The JDK 1.5 Executor framework is a combination of various Executor interfaces and Executors utility class to provide a thread pool feature in Java.  In server side programming, Thread pool is an important concept to maintain scalability, robustness, and stability of the system.   Thread pool is a pool of worker threads, which is ready to perform any task given to them, […]

Defining and Starting a Thread | Thread VS Runnable

Java threads are objects like any other Java objects. Threads are instances of class java.lang.Thread, or instances of subclasses of this class. In addition to being objects, java threads can also execute code. Creating and Starting Threads Here is the code to create a Thread and start its execution. // Creates Thread Object Thread thread = […]

CountDownLatch Vs CyclicBarrier | Java Concurrency Utilities

CountDownLatch Vs CyclicBarrier : Though both are used as a synchronization aid that allows one or more threads to wait but there are certain differences between them that you should know in order to know when one of these utilities will serve you better.  As per the java.util.concurrent API,  CountDownLatch: A synchronization aid that allows one or more threads to […]

CyclicBarrier | Java Concurrency Utilities

May 25, 2017
Posted by Abhi Andhariya

CyclicBarrier  was introduced in Java 5 along with other concurrent classes like CountDownLatch, ConcurrentHashMap, CopyOnWriteArrayList, BlockingQueue within java.util.Concurrent package. There are scenarios in concurrent programming when you want set of threads to wait for each other at a common point until all threads in the set have reached that common point.  The java.util.concurrent.CyclicBarrier class is a barrier that […]

InterruptedException in Java Multithreading

InterruptedException is thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted, either before or during the activity. Before reading this article, I recommend you to go through my article interrupt(), interrupted() and isInterrupted() in Java Multithreading. There are some methods in JDK that check the Interrupt status flag for us and throw InterruptedException, if it […]

interrupt(), interrupted() and isInterrupted() in Java Multithreading

In this post, we will understand about interrupt(), interrupted() and  isInterrupted() methods in Java Multithreading. If you are interested in reading more about interruption mechanism you can look into our post InterruptedException in Java Multithreading. In Java, thread starts its execution when we call start() method on Thread object. It internally calls overridden run() method. Thread is said to be terminated when […]

CountDownLatch in Java Concurrency Utilities

May 5, 2017
Posted by Abhi Andhariya

CountDownLatch in Java Concurrency is a type of synchronizer which allows one Thread to wait for one or more Threads before it starts processing. You can implement the same functionality using wait() & Notify() mechanism but it requires lot of code and getting it write in first attempt is tricky,  With CountDownLatch it can  be done in […]

Producer Consumer Design Pattern

April 5, 2017
Posted by Abhi Andhariya

Producer Consumer Problem is a classical concurrency problem. In fact it is one of the concurrency design pattern.  It is also known as the bounded-buffer problem. The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue. The producer's job is to generate data and put it into […]

Producer Consumer Design Pattern using BlockingQueue

April 5, 2017
Posted by Abhi Andhariya

Producer Consumer Problem is a classical concurrency problem. In fact it is one of the concurrency design pattern.   This article is continuation of my post Producer Consumer Design Pattern in which I have explained basic idea, real life example, uses and benefits of Producer Consumer Design Pattern.   Producer Consumer Design Patter can be implemented using […]

Previous Posts Next posts
Total Posts : 124
follow us in feedly

Like Us On Facebook