Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a JAVA program that would simulate traffic lights using the concept of Multithreading. One example is shown in the following figure. Each light has

Write a JAVA program that would simulate traffic lights using the concept of Multithreading. One example is shown in the following figure. Each light has two statuses, "on" and "off". Moreover, the time of each light switching status can be set using the text input box beforehand. If the user clicks on the "Start" button, the program starts to work. While if the "End" button is clicked, the program stops working but not terminates. The program terminates only when the "X" button on right-upper corner. Please note that initially the switching time for each light would be set to "3". As shown in the last column of the following figure, you should also display the text indicating the status of the traffic light.

image text in transcribed

I have found answer of this program but it is not working and you can check the error pop up box image down below. can you please solve this for me?

image text in transcribed

Green Green Yellow Red Yellow 3 Start Stop stop Traffic light demo change light color now light:l after 2 seconds will change color now light:1 after1 seconds will change color now light :1 after 0 seconds ill change color change lisht color now light:2 after 2 seconds will change color now light:2 after 1 seconds will change color now light:2 after 0 seconds will change color change 1ight color Green Yellow Red Green Green Yellow Red Yellow 3 Start Stop stop Traffic light demo change light color now light:l after 2 seconds will change color now light:1 after1 seconds will change color now light :1 after 0 seconds ill change color change lisht color now light:2 after 2 seconds will change color now light:2 after 1 seconds will change color now light:2 after 0 seconds will change color change 1ight color Green Yellow Red

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago