Python Programming Questions
Print fibonacci
number using recursion.
def fib(x):
if
x == 0
or x
== 1:
return x
else:
return (fib(x-1) + fib(x-2))
for i
in range(10):
print(fib(i))
Print the char and number of occurrences...
How to calculate the sum of numbers in list asynchronously?
We will be using ExecutorService from Executor framework and
Future interface to make asynchronous calls.
We will be using Streams from Java 8 to calculate the sum of
integers in the list.
import java.util.List;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
public class SumCalculator implements Callable
{
...
How to combine result of two threads in java?
Let us consider a scenario where you want to make multiple
service calls and combine the results at the end.
There are multiple ways how this can be achieved, we are
going to see how we can do the same using Future and ExecutorService in java.
Let us first understand how and where Future class has to be
used.
As per Javadoc a Future is...