Marker Interface example in Java

Introduction The marker interface pattern is a design pattern that provide run-time type information about objects. It provides a means to associate metadata with a class when there is no explicit support for such metadata. Marker interfaces in Java, e.g., Serializable, Clonnable…

Externalization example in Java

The Externalizable interface provides the necessary means for implementing a custom serialization mechanism. Implementing the Externalizable interface means that we must override writeExternal() and readExternal() methods. These methods will be called when you serialize or deserialize a particular instance or object. The…

How ThreadLocal works in Java

Introduction We will see how ThreadLocal works in Java. Java ThreadLocal class is used to create thread-local variables. The thread-local variable can be read and written by the same thread only. In multi-threaded environments all of the threads of an Object share…