Submitted by heartin on Fri, 11/07/2014 - 01:16
Lock ordering deadlock is caused when using different order of acquiring locks when locking on multiple objects. The solution is also simple: either acquire only one lock at a time or when acquiring multiple locks, acquire them in same order, whenever feasible.
Submitted by heartin on Fri, 11/07/2014 - 01:09
According to the book Java Concurrency in Practice, there are different types of deadlocks such as Lock ordering deadlocks, Open call deadlocks and Resource deadlocks. All the examples in this note are inspired from the examples given in the book Java Concurrency in Practice.
Lock ordering deadlock is caused when using different order of acquiring locks when locking on multiple objects.
Submitted by heartin on Thu, 11/06/2014 - 03:58
Gradle gives us the freedom to create our own tasks if none of the existing tasks are fit for our need. One of the ways for creating a task type is to create it as below from within the build file:
class MyTask extends DefaultTask {
def prop1 = 'value1'
…
@TaskAction
def myMethod1() {
…
}
}
Submitted by heartin on Sat, 10/25/2014 - 22:16
The main method is the entry point to a desktop based core Java application.
Previously, we created our first Java program "Hello.java" as:
public class Hello {
public static void main(String[] args)
{
System.out.println("Hello");
}
}
We then compiled it using javac as:
javac Hello.java
We then executed it as:
java Hello
And output should be:
Hello
Submitted by heartin on Fri, 10/24/2014 - 22:42
To access a class or method from another package we need to either use the fully qualified name (e.g. com.javajee.MyClass) or we can use the import statements.
Using import statement
You can use an import statement to import a single class (import java.util.List;) or all classes of a package (import java.util.*;). Remember that you can import only types (classes and interfaces, but not methods) using a regular import.
Consider an example:
Pages