Question: (JAVA) Explain in a few sentences (1-5) the behavior of the following program (what does the program trying to do, input, and output?). You may

(JAVA) Explain in a few sentences (1-5) the behavior of the following program (what does the program trying to do, input, and output?). You may want to run the above code with a big enough input integer to check the execution time.

(JAVA) Explain in a few sentences (1-5) the behavior of the following

import java.util.Scanner; import java.util.concurrent.*; class Summation implements Callable { private int upper; public Summation(int upper) { this.upper = upper; } /* The thread will execute in this method */ public Integer call() { int sum = 0; for (int i = 1; i result = pool.submit(new Summation (upper)); System.out.println("sum = + result.get()); } catch (InterruptedException | ExecutionException ie) { System.out.println("Error executing the task!"); } long endtime = System. nanoTime(); // get execution time long timeElapsed = endTime - startTime; System.out.println("Total execution time: timeElapsed / 1000000 + ms"); pool.shutdown(); } } +

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!