Category : Concurrency

Transactions are an essential part of any business critical application as these ensure the integrity of the data being managed by the same application. Transactions ensure that the data remains in a consistent and integral state after this is manipulated, thus mitigating the risk of invalid states. Databases are synonymous with transactions, and many programming languages rely on the underlying database to provide the required transactional support. This works well when all modified state is found at the database level. Unfortunately, this is not always the case and there can be cases where the state is found at the application level rather than the database level. In this article we will see how we can use Multiverse (Git Hub), a Software Transactional Memory, to provide transactions at the software level without using any databases.

Albert Attard
Author: 2 years ago

The Singleton (Wiki) pattern is quite an old and well known pattern. This pattern was discussed over and over again in many books and articles on the web. So why are we discussing it again here? This article is not about the Singleton pattern per se, but more about the Java Memory Model (Paper) and the concurrent access of shared objects.

Albert Attard
Author: 3 years ago

Java 7 introduced a new type of ExecutorService (Java Doc) called Fork/Join Framework (Tutorial), which excels in handling recursive algorithms. Different from other implementations of the ExecutorService, the Fork/Join Framework uses a work-stealing algorithm (Paper), which maximise the threads utilisation, and provides a simpler way to deal with tasks which spawn other tasks (referred to as subtasks).

Albert Attard
Author: 3 years ago

Say that you are eating some sweets while watching a movie. You had a look at your pack or sweets, counted five and continued watching the movie. Took the first one and deducted this in your mind (without looking at the sweets pack). In the mean time, and without you knowing, your daughter takes one. While you think that there are four sweets left, in reality there are only three. You will discover this at the end when you are looking for the last one. This is a Race Condition and in this article we will see how this occurs in programming and how we can avoid it.

Albert Attard
Author: 3 years ago

This tutorial demonstrates how to develop a simple Java Swing (or user interface) application and test the UI related logic using automated tests, such as JUnit (Homepage), using a series of videos compiled as a playlist (Youtube). The application is kept very simple while making use of various technologies, such as EasyMock (Homepage). This tutorial is targeted to college or university students who studied Java but lack experience and would like to do something productive. The main idea of this tutorial is not to learn Java, but to help the viewers to build testable Swing applications. The playlist presented by this tutorial shows how to build a Java Swing application that can be easily tested using automated tests in a step-by-step fashion.

Albert Attard
Author: 4 years ago

Imagine you are waiting for a call from your girlfriend with whom you had an argument. She too is waiting for you to call her and apologise. In other words, both of you are waiting for the other to call. Now if no one takes the phone and calls the other, you will never talk again. This is a deadlock and in this article we will see how deadlock occurs in programming and how to prevent it.

Albert Attard
Author: 4 years ago

In Java 5, a new set of classes related to concurrency was added to the Java API, mostly authored by the famous Doug Lea. These include the ExecutorService (Java Doc) and the Future (Java Doc) classes to name a few, all part of the concurrency framework which was introduced in the same version of Java (Concurrency Utilities Overview). This article describes a problem related with stopping a group or Future in time. It first shows the problem and then proposes a simple solution.

Albert Attard
Author: 5 years ago

Java provides a neat way to carry out long lasting jobs without have to worry about the complexity of threads or lack of responsiveness in an application (by application we mean Swing applications). It is called SwingWorker (Java Doc). It is not the latest thing on Earth (released with Java 1.6) and you may have already read about it. In this article we will see how to use it and why it was created to start with.

Albert Attard
Author: 5 years ago