A) Write a Thread class (called worker) that takes two numbers (A and B, A < B) and calculates the products of all numbers between A and B. the result is stored in a local variable than can be accessed through a get method. B) Write a main program to calculate the factorial of a given number n (factorial(n) = 1 x2x3x.xn). The main thread reads n from the user, then creates two instances of Worker. Each one is requested to calculate the half of numbers between 1 and n. Once they finish, the main thread will gather their results and print the final result (result1 x result2).

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter11: Operating Systems
Section: Chapter Questions
Problem 14VE
icon
Related questions
Question
Java program
A) Write a Thread class (called worker) that takes two numbers (A and B,
A < B) and calculates the products of all numbers between A and B. the
result is stored in a local variable than can be accessed through a get
method.
B) Write a main program to calculate the factorial of a given number n
(factorial(n) = 1 x2x3x.xn). The main thread reads nfrom the user, then
creates two instances of Worker. Each one is requested to calculate
the half of numbers between 1 and n. Once they finish, the main thread
will gather their results and print the final result (result1 x result2).
Example when n=10
Worker 1: calculates 1 x2x3x4x 5
Worker 2: calculates 6 x7x8×9x 10
Transcribed Image Text:A) Write a Thread class (called worker) that takes two numbers (A and B, A < B) and calculates the products of all numbers between A and B. the result is stored in a local variable than can be accessed through a get method. B) Write a main program to calculate the factorial of a given number n (factorial(n) = 1 x2x3x.xn). The main thread reads nfrom the user, then creates two instances of Worker. Each one is requested to calculate the half of numbers between 1 and n. Once they finish, the main thread will gather their results and print the final result (result1 x result2). Example when n=10 Worker 1: calculates 1 x2x3x4x 5 Worker 2: calculates 6 x7x8×9x 10
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning