Sanat Vij

Subscribe to Sanat Vij: eMailAlertsEmail Alerts
Get Sanat Vij via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Top Stories by Sanat Vij

A deadlock is a situation where two or more threads are blocked while waiting to obtain locks that some of the other threads in the deadlock are holding. Deadlocks can occur when multiple threads need the same locks, at the same time, but obtain them in different order. For instance, if thread 1 locks A, and tries to lock B, and thread 2 has already locked B, and tries to lock A, a deadlock arises. Thread 1 can never get B, and thread 2 can never get A. In addition, neither of them will ever know. They will remain blocked on each of their objects, A and B, forever. Deadlock Detection The most common way of detecting whether your application is deadlocked is by analyzing thread dumps of the Java Virtual Machine while its in the state of appearing hung. A thread dump is a snapshot of the virtual machine's current state, including stack traces for each Java thread. Th... (more)

The Disruptor Framework: A Concurrency Framework for Java

Let's start with the basic question: What is the disruptor? The disruptor is a concurrency framework for Java that allows data sharing between threads. The age old way of coding a producer-consumer model is to use a queue as the buffer area between the producer and the consumer, where the producer adds data objects to the queue, which are in turn processed by the consumer. However, such a model does not work well at the hardware level and ends up being highly inefficient. The disruptor in its simplest form replaces the queue with a data structure known as the ‘ring buffer'. Which... (more)

Next-Gen Concurrency in Java: The Actor Model

At a time where the clock speeds of processors have been stable over the past couple of years, and Moore's Law is instead being applied by increasing the number of processor cores, it is getting more important for applications to use concurrent processing to reduce run/response times, as the time slicing routine via increased clock speed will no longer be available to bail out slow running programs. Carl Hewitt proposed the Actor Model in 1973 as a way to implement unbounded nondeterminism in concurrent processing. In many ways this model was influenced by the packet switching m... (more)