Quantcast
Channel: Tech Tutorials
Browsing all 970 articles
Browse latest View live

Difference between ReentrantLock and Synchronized in Java

From Java 5 new lock implementations have been provided like ReentrantLock, ReentrantReadWriteLock which provide more extensive locking operations than can be obtained using synchronized methods and...

View Article


Image may be NSFW.
Clik here to view.

Exchanger in Java concurrency

Exchanger is one of the Synchronization class added along with other synchronization classes like CyclicBarrier, CountDownLatch, Semaphore and Phaser in java.util.concurrent package. How does Exchanger...

View Article


How to sort an ArrayList in descending order

When you add elements to an ArrayList, elements are added in sequential order and while iterating an arraylist same sequential order will be used. But sometimes we do have a requirement to sort an...

View Article

ReentrantReadWriteLock in Java

Even in a multi-threading application multiple reads can occur simultaneously for a shared resource. It is only when multiple writes happen simultaneously or intermix of read and write that there is a...

View Article

How to read file from the last line in Java

There are applications where you have to read huge files line by line may be using some tool like Pentaho, Camel. Let's say these files are in the format header, records and footer and you need to...

View Article


Semaphore in Java Concurrency

Semaphore is one of the synchronization aid provided by java concurrency util in Java 5 along with other synchronization aids like CountDownLatch, CyclicBarrier, Phaser and Exchanger.The Semaphore...

View Article

BlockingQueue in Java Concurrency

BlockingQueue, an interface is added in Java 5 with in the java.util.concurrent package which provides many other concurrent utilities like CyclicBarrier, Phaser, ConcurrentHashMapa, ReentranctLock...

View Article

ArrayBlockingQueue in Java Concurrency

ArrayBlockingQueue which is an implementation of the BlockingQueue interface was added in Java 5 along with other concurrent utilities like CopyOnWriteArrayList, ReentrantReadWriteLock, Exchanger,...

View Article


How to add double quotes to a String in Java

You may come across a scenario when you would want to add double quotes to a String, but Java uses double quotes while initializing a String so it won't recognize that double quotes should be added...

View Article


Difference between HashMap and ConcurrentHashMap in Java

ConcurrentHashMap was added in Java 5 as an alternative for HashTable to improve the performance of the (key, value) pair kind of data structure while still keeping it thread safe. On the other hand...

View Article

Injecting prototype bean in singleton bean in Spring

If we go by the definition of the singleton and prototype beans, it says - Singleton scope - Only one shared instance of a singleton bean is managed by the container, and all requests for beans with an...

View Article

Different bean scopes in Spring

When you create a bean definition, you provide a configuration for creating actual instances of the class defined by that bean definition. By providing bean definition you can control not only, the...

View Article

static block in Java

Static block is used for static initializations of a class. Consider the scenario when initialization of static variables requires some logic (for example, error handling or a for loop to fill a...

View Article


Initializer block in Java

If you want to initialize an instance variable you will put that code in a constructor. There is one alternative to using a constructor to initialize instance variables which is called initializer...

View Article

CopyOnWriteArraySet in Java Concurrency

In Java 5 many concurrent collection classes are added as a thread safe alternative for their normal collection counterpart which are not thread safe. Like ConcurrentHashMap as a thread safe...

View Article


Difference between ArrayList and CopyOnWriteArrayList in Java

CopyOnWriteArrayList was added in Java 5 as a thread-safe alternative to ArrayList, which is one of the most used collection along with HashMap.In this post we'll see the difference between the...

View Article

Image may be NSFW.
Clik here to view.

Spring bean life cycle

Lifecycle of a bean in a Spring is quite elaborate and provides many callback methods to customize the nature of the bean. On the basis of functionality, these callback methods provide, you can...

View Article


ConcurrentSkipListMap in Java

ConcurrentSkipListMap is a scalable concurrent map which implements ConcurrentNavigableMapinterface. Though concurrent collections like ConcurrentHashMap and CopyOnWriteArrayList were added in Java...

View Article

ConcurrentSkipListSet in Java

ConcurrentSkipListSet is a scalable concurrent set which uses ConcurrentSkipListMap internally. Though concurrent collections like ConcurrentHashMap and CopyOnWriteArraySet were added in Java 1.5,...

View Article

LinkedBlockingQueue in Java

LinkedBlockingQueue which is an implementation of BlockingQueue interface is added in Java 5 along with other concurrent utilities like CyclicBarrier, Phaser, ConcurentHashMap, CopyOnWriteArraySet...

View Article
Browsing all 970 articles
Browse latest View live


Latest Images