Blogs

Java Concurrency Series- How to use Lock/RentrantLock in Java 5

Average: 5 (2 votes)

In this article, we will examine the subtleties of using newly introduced Lock classes in java.util.concurrent.locks package and their advantages over traditional "synchronized" blocks and methods.

Java Concurrency Series- How to use Future/FutureTask and Callable

Average: 4.4 (11 votes)

In this article we will discuss how to use the new interface Callable introduced in java.concurrent.util in Java 5. Callable along with another interface Future allows us to obtain a return value from a method executed in a separate thread.
In the second example we will also examine the usage of FutureTask, an implementation of Future.

Java Concurrency Series - another Executor example

Average: 4 (1 vote)

In an earlier article on Executor, we looked at how we can create use the executor to create thread pools to manage our multi-threaded program. We shall continue to explore additional features of this class.
Here we will extend the ThreadPooledExecutor class and provide our implementation to replace the empty implementation.

Java Concurrency Series - meaning of volatile variable

Tagged:  
Average: 3 (2 votes)

One of the least understood aspects of Java Thread model is the "volatile" keyword. The general misconception is that if you make a variable volatile you don't need to provide synchronized access to it.
Let's create a simple class with a integer marked as volatile. There are two methods which increment and decrement the variable in a for loop. To increase interleaving of the threads, we have a call to yield inside the for loop.

Code snippet 1

  1. public class VolatileExample {
  2.        
  3.         private volatile int volatileInt=0;
  4.        
  5.         /** unsynchronized volatile variable being incremented */

Java Concurrency Series - Simple Executor example

Tagged:  
Average: 4.1 (8 votes)

With Java 1.5 we have a new way of managing threads or threaded tasks. We no longer need to call start() and join()on our Thread object. The new concurrent package provides us with an elegant Executor class to manage our threads.

Let's go through a simple example given below. We have created a simple ThreadPool with default pool size of 2 and max size of 4. In the method createMultipleConsumerThreads(), we have created an instance of a Runnable task, Consumer and passed it on to the execute() method.

Grails - How to create groovy domain classes from mysql database

Tagged:  
Average: 2.5 (2 votes)

Recently I started working with Grails and I am very much impressed with its capabilities and kind of digging deep now.

Being used MyEclipse extensively I started searching for tool to create groovy domain objects from mysql database. But no luck I couldn't able to find any tools or scripts. So I created one which suits my needs presently. Feel free to use it any way you like.

Features

- Converts Plural table names to Singular form
- Removes underscores (_) and capitalizes first letter of every word.

Java Concurrency Series with examples- Barrier

Tagged:  
Average: 4 (3 votes)

In this series we will discuss different concurrent structures provided in the new Java 5 Concurrent package.
We will start with a simple parallel processing concept called "barrier" that we have all studied and forgotten. By definition if there are set of independent tasks (T1..Tn) that need to fully completed to initiate another task (Tx) which is dependent on all these tasks (T1...Tn) we can synchronize them using a barrier.

Introduction to Real Time Java - Part 1

Tagged:  
No votes yet

Recently I attended a seminar on Real-Time Java by Eric Bruno. It was informative seminar about real time systems and their uses and where Real-Time java comes in to the picture with some examples and demos. So lets get in to details

Syndicate content