Threadpool using Executor Framework | Java Concurrency Utilities
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, […]
Callbacks and Promises | Javascript
In this article we will discuss about callback functions and promise in javascript. Callbacks and Promises are very important concepts of javascript as it helps it to support and leverage its asynchronous behaviour. First we explore on callback function and then promises. Callbacks: Let's first define the callback function: Callback function is any function that […]
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 = […]
Mediator Design Pattern
Mediator Design Pattern is one of the Behavioral Design Pattern. With the Mediator Design Pattern, communication between objects is encapsulated with a mediator object. Objects no longer communicate directly with each other, but instead communicate through the mediator. This reduces the dependencies between communicating objects, thereby lowering the coupling. Definition GoF Definition: Define an object that encapsulates […]
Observer Design Pattern
Observer Design Pattern is one of the Behavioral Design Pattern. Observer design pattern is useful when you are interested in the state of an object and want to get notified whenever there is any change. Definition GoF Definition : The Observer Design Pattern defines a one-to-many dependency between objects so that when one object changes state, all […]
UNION Vs UNION ALL | Oracle SQL
Though both UNION and UNION ALL is used to combine results of two SELECT queries, the main difference between them is that UNION doesn't include duplicate records, but UNION ALL does. Another difference between them is that UNION ALL is faster than UNION , but may look slow because it returns more data which takes more […]
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
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 […]
final keyword in Java
final is a keyword in Java. It can be used with variable, method or class. In this article we will see how we can make variable, method or class final in java and what are the advantages of doing so. If we make a method final, we can not override it in subclass.If we make […]
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 […]