4. At line n2, insert CyclicBarrier cb = new CyclicBarrier(master);
Correct Answer : Get Lastest Questions and Answer : Explanation: java.util.concurrent.CyclicBarrier.CyclicBarrier(int parties, Runnable barrierAction)
Creates a new CyclicBarrier that will trip when the given number of parties (threads) are waiting upon it, and which will execute the given barrier action when the barrier is tripped, performed by the last thread entering the barrier. Parameters: parties the number of threads that must invoke await before the barrier is tripped barrierAction the command to execute when the barrier is tripped, or null if there is no action
Question : You have been given below code, what is the expected output?
package com.hadoopexam;
import java.util.function.ToIntFunction;
public class Welcome { public static void main(String[] args) { String message = "Welcome to HadoopExam Learning Resources"; ToIntFunction index = message::indexOf; int position = index.applyAsInt("H"); System.out.println(position); } }
@FunctionalInterface Represents a function that produces an int-valued result. This is the int-producing primitive specialization for Function. This is a functional interface whose functional method is applyAsInt(Object). Parameters: the type of the input to the function
int java.util.function.ToIntFunction.applyAsInt(String value)
Applies this function to the given argument. Parameters: value the function argument Returns: the function result