Mar Java Mit Java - Page 2 of 20 - Get deeper into java

Mar Java Mit Java Blog

Implement a Reentrant Lock in Java 0

Implement a Reentrant Lock in Java

Let’s try to implement our own custom Lock. For sake of simplicity we will not implement interruptible, non-interruptible, and timed forms of the lock /* * For sake of simplicity – assume custom lock...

How is Java Lock better than Synchronization 0

How is Java Lock better than Synchronization

Here are few benefits of using Java’s Lock API over Synchronization 1.Java Lock API provides more visibility and options for locking, unlike synchronized where a thread might end up waiting indefinitely for the lock,...

When should we use Volatile variables 0

When should we use Volatile variables

In general each thread has its own copy of variable, such that one thread is not concerned with the value of same variable in the other thread. But sometime this may not be the...

How to use Jedis in multi threaded environment 0

How to use Jedis in multi threaded environment

Jedis instances are single threaded Don’t use the same Jedis connection instance from multiple threads at the same time. Using the same Jedis instance from multiple threads at the same time will result in...

How to catch exception thrown by a thread 0

How to catch exception thrown by a thread

In this example we will see how to use Thread.UncaughtExceptionHandler. UncaughtExceptionHandler is used as a way to provide an elegant way to handle Runtime Exceptions which are not handled otherwise in the programs. As...