Getting started with Git

Git is a distributed version control system - unlike traditional version control systems like CVS or SVN where there's one repository where everyone works ( check out something, make changes and push it back to the same repository) git follows a distri...

Drools

Drools is a Java-based business rule management system (BRMS) based on an enhanced implementation of a the Rete algorithm (a pattern matching algorithm developed to efficiently control triggering of rules). KIE (Knowledge Is Everything) is the new umbr...

Actor based parallelism using Scala and Akka : Part 2

Dispatchers in Akka Dispatchers are used to control the flow of execution in Akka - they can control how messages are being sent, delivered, received and processed. Based on the dispatching policy, dispatchers will route the incoming message to respe...

Actor based parallelism using Scala and Akka : Part 1

Threads and locks are popular programming constructs because they tend to mimic what the underlying hardware does. However, use of threads and low level concurrency features require developers to have in-depth knowledge of memory model and often inner ...

Bi-temporal database design

Today, databases are the primary system of record, and organizations (especially heavily regulated ones) are required to keep an accurate picture of all the facts, as they occur. Most organizations manage data that changes over time. If you are in a re...

Scala Futures

A Future instance represents the result of an asynchronous computation. Future is a lightweight parallelism API provided as part of Scala core. Scala Futures are easily interoperable with Java Futures and executor-service implementations To use Future...

Getting started with JIRA REST API

JIRA allows programmatic access to data through it's Java based REST API. Essentially every call to the Java API translates to an HTTP request to the JIRA REST Services. The JIRA REST API uses JSON as its communication format, and the standard HTTP me...

Java Memory Model

The Java memory model describes how threads in the Java programming language interact through memory. Together with the description of single-threaded execution of code, the memory model provides the semantics of the Java programming language.In single...

Spring : creating unique beans per thread

In stand-alone non-web Java applications, using Spring, the most commonly used bean scopes are singleton and prototype. If a bean scope is set to singleton (and by default bean scope is always singleton), the Spring container creates exactly one instan...

False Sharing

Most modern day computer architectures have a tiered memory structure. Cache memory is really fast (SRAM) and is also physically located very close to the processor (L1 is placed on CPU chip closest to processor, L2 is placed in between CPU and RAM, i...

CopyOnWriteArrayList and CopyOnWriteArraySet

CopyOnWriteArrayList CopyOnWriteArrayList uses an interesting technique to make it thread-safe without a need for synchronization - all mutative operations (add, set, and so on) are implemented by making a fresh copy of the underlying array. This is or...

ConcurrentHashMap

A ConcurrentHashMap is a thread safe implementation of a hash table data structure. A ConcurrentHashMap has the same functional specifications as HashTable with the performance benchmarks comparable to a HashMap. Before we look into ConcurrentHashMap's...

Transfer Queue

A transfer queue is a special type of BlockingQueue (it implements BlockingQueue) where producers may optionally wait until consumers have consumed the corresponding element. Like other blocking queues, a TransferQueue may be capacity bounded. If so, ...

Common inter thread communication problems

Sleeping Barber Problem In computer science, the sleeping barber problem is a classic inter-process communication and synchronization problem between multiple operating system processes. The analogy is based upon a hypothetical barber shop with one bar...

Hardware Based Locking

CAS (Compare And Swap) : CAS ( Compare And Swap) is an atomic instruction used to implement optimistic locking. It compares the contents of a memory location with a given value and, only if they are the same, modifies the contents of that memory locati...

Executor Framework in Java

Executor is a framework provided by the JDK (starting 1.5) which simplifies the execution of tasks in asynchronous mode. At a high level, the Executor classes provide abstraction for assigning tasks to a pool of threads. The java.util.concurrent packag...

Synchronization tools for coordinating between threads

Apart from the low level synchronization abstractions (synchronized/Lock/Semaphore), Java also provides a bunch of high level abstractions for synchronizing activities of two or more threads. Let's have a closer look at some of them CountdownLatch Coun...

Reflection and String immutability

One very powerful but risky tool is Reflection. Using reflection, you can break almost everything - from encapsulation to immutability Here is a piece of code which breaks immutability of String class import java.lang.reflect.Field; public class Muta...

ThreadLocal

The ThreadLocal class helps us maintain 'per thread' semantics. Thus, even if two threads are executing the same code, and the code has a reference to a ThreadLocal variable, then the two threads cannot see each other's values. This is especially helpf...