Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Programming questions Imagine you have a static ArrayList that contains a list of numbers(Integer). Your task is to create two threads. One thread is

JAVA Programming questions

Imagine you have a static ArrayList that contains a list of numbers(Integer). Your task is to create two threads. One thread is adding random new numbers(1~100) into the list every 1 second. The second thread is removing all the odd numbers, and printing the list on the screen every 1.5 seconds.

Your program should never end and please make sure to handle any race condition to avoid the ConcurrentModificationException.

Please check below for a sample output.

[] [] [48] [48] [48, 2] [48, 2, 8] [48, 2, 8, 80, 90] [48, 2, 8, 80, 90] [48, 2, 8, 80, 90, 94] [48, 2, 8, 80, 90, 94, 28] [48, 2, 8, 80, 90, 94, 28, 80] [48, 2, 8, 80, 90, 94, 28, 80, 40]

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

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

=+Where do you want to live and work?

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago