Code Pumpkin

Tag Archives: Java

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 […]

Transient Keyword In Java

May 13, 2017
Posted by Dipen Adroja

The transient keyword in java is used on class attributes to indicate that serialization process of such class should ignore such attributes for any instance of that class. When JVM comes across transient keyword, it ignores original value of the variable and save default value of that variable data type. transient keyword plays an important […]

Stream API | Java8

May 12, 2017
Posted by Dipen Adroja

In this article, we are going to walk through Stream API which is introduced as a part of Java8. Using Stream API, we can make our collection manipulation more declarative and thread safe in case of multi-threaded environment with very ease. The advantage of using Stream API to manipulate collections is we only ask the […]

How does HashMap work internally in Java?

May 4, 2017
Posted by Abhi Andhariya

How does HashMap work internally in java is one of the most asked core java interview questions. Most of the candidates do not give the satisfactory explanation. This question shows that candidate has good knowledge of Collection. So this question should be in your TO-DO list before appearing for the interview. There are four things we should […]

Builder Design Pattern

April 27, 2017
Posted by Abhi Andhariya

Builder design pattern is a creational design pattern like Factory Pattern and Abstract Factory Pattern. For better understanding of  any  design pattern, You should know the problems faced by programmers before that design pattern was introduced. What are the traditional ways of creating an object of a class? We can provide either constructor or a static factory method to get the object  of […]

How to create Immutable Class in Java

Immutable class is a class which once created, it's contents can not be changed. In other words, Immutable objects are the objects whose state can not be changed once constructed.  In Java, String and all the wrapper classes e.g. Boolean, Integer, Long, etc are immutable classes. We can also create our own immutable class.  Why should we write Immutable Classes? Here are […]

Wrapper Classes | Interview Questions

April 22, 2017
Posted by Abhi Andhariya

In this post, we will discuss some of the most asked interview questions on wrapper classes. Java is an object-oriented language and can view everything as an object. A simple file can be treated as an object (with java.io.File), an address of a system can be seen as an object (with java.util.URL) and an image can be treated as an […]

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

Like Us On Facebook