Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

More Books

Students also viewed these Databases questions