Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose you have a MAP of integers of size 100 filled as keys from 1 to 1000 and values are random integers. Write a Java

Suppose you have a MAP of integers of size 100 filled as keys from 1 to 1000 and values are random integers. Write a Java code to create two threads to empty the MAP from its elements in a random fashion. The first one removes data from the MAP as follows: it generates a random number between 1 and 100 (represents some key in the MAP) and removes the entry of that number (of course it is possible that it generates the random number several times). This thread keeps removing data till it is notified by the second thread. The second thread keeps checking the if there are still elements in the MAP or not, if the MAP becomes empty, it notifies the 1st thread to stop the removing process. As the program ends, it prints how many second this process took, the seconds are calculated by a third thread.

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

Step: 3

blur-text-image

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

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions