1. Future cancel() API The Future.cancel() method takes one argument of typeboolean boolean cancel(boolean mayInterruptIfRunning); Depending on the value of mayInterruptIfRunning and the status of the task submitted to the executor, the behavior of this method is different: If the task has been completed or has been canceled earlier, or it can’t be cancelled due to any other reason, the…
Executor RejectedExecutionHandler 1. When tasks get rejected Remember, when we finish the execution of an executor, we use the shutdown() method. The executor waits for the completion of tasks that are either running or waiting for their execution. Then, it shuts down the executor. If we send a task to an executor between invoking the shutdown() method and the end…
1. ConcurrentHashMap class The ConcurrentHashMap is very similar to the HashMap class, except that ConcurrentHashMap offers internally maintained concurrency. It means we do not need to have synchronized blocks when accessing its key-value pairs in a multithreaded application. //Initialize ConcurrentHashMap instance ConcurrentHashMap<String, Integer> m = new ConcurrentHashMap<>(); //Print all values stored in ConcurrentHashMap instance for each (Entry<String, Integer> e : m.entrySet()) { system.out.println(e.getKey()+”=”+e.getValue()); } The…
1. Deadlock In Java, a deadlock is a situation where minimum two threads are holding the lock on some different resource, and both are waiting for the other’s resource to complete its task. And, none is able to leave the lock on the resource it is holding. ResolveDeadLockTest.java package thread; public class ResolveDeadLockTest { public static…
A Stream in Java can be defined as a sequence of elements from a source. The source of elements here refers to a Collection or Array that provides data to the Stream. Java streams are designed in such a way that most of the stream operations (called intermediate operations) return a Stream. This helps to create a chain of stream operations. This is…
GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement You should try different dialects likeorg.hibernate.dialect.MySQL5Dialect OR org.hibernate.dialect.MySQLMyISAMDialect OR org.hibernate.dialect.MySQLInnoDBDialect to see which one works for you. Solution 1 You should try different dialects likeorg.hibernate.dialect.MySQL5Dialect OR org.hibernate.dialect.MySQLMyISAMDialect OR org.hibernate.dialect.MySQLInnoDBDialect to see which one works for you. All in all, your current dialect is generating,type=MyISAM while it should be, ENGINE=MyISAM in create table query. mysql…
What is Linked List ? A linked list is a linear data structure containing interconnected nodes through pointers. Since there is no concept of pointers in Java, each node holds the reference of another node, but the last element of the linked list refers to NULL, meaning the end of the list. A linked list…
Is a relationship is also known as inheritance. We can implement ‘is a’ relationship or inheritance in java using extends keyword. The advantage or inheritance or is a relationship is reusability of code instead of duplicating the code. Ex : Motorcycle is a vehicle Car is a vehicle, Both car and motorcycle extends vehicle.