February 19, 2019

Wait, notify and notifyall. What is the difference between notify and notifyall.

Q1 :- How does Java maintains a record of threads waiting on an object? Ans :- Each object has a waiting set. Every time a thread  calls wait on an object, that thread gets added in that waiting-set. So, a Set datastructure is used to maintain the record of waiting threads in java. Q2 :- What is the difference […]

Read more
December 4, 2018

Simple implementation for Callable interface in Java, using lambda.

In this tutorial, we will learn basic implementations for Callable interface  using lambda in java. Anonymous Class providing an implementation for Callable interface. Callable<String> callMyName = new Callable<String>() { @Override public String call() throws Exception { return “Anurag Anand”; } }; You can submit the above implementation to return any string value. The same can be […]

Read more
November 30, 2018

Using lambda and Functional Programming to provide implementation for Callable interface – which prints a string n number of times in java

Callable is a Functional interface, it is similar in usage to Runnable interface. But with a small difference, that Callable can return a value, while Runnable can not return a value. In this tutorial, we will create a Callable which will return a String output. The string output is going to return String Value, which will be contain a given word  repeated n number of times. Given Values :- […]

Read more