subject

write a program that consists of two threads. The first is the main thread that every Java application has. The main thread should create a new thread from the Runnable object, MessageLoop, and wait for it to finish. If the MessageLoop thread takes too long to finish, the main thread should interrupt it. Use a variable named maxWaitTime to store the maximum number of seconds to wait. The main thread should output a message stating that it is still waiting every half second. The MessageLoop thread should print out a series of 4 messages. These messages should be numbered, as in the example below. It should wait 850 milliseconds between printing messages to create a delay. If it is interrupted before it has printed all its messages, the MessageLoop thread should print "Message loop interrupted" and exit. Or you can let main print "Message loop interrupted". Your program must demonstrate that it can both output messages and interrupt the message output. To do this, place the body of main into a for loop using maxWaitTime as the index. As in the following example, it should finally output all 4 messages in the last iteration. So in main your code will be

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:50
Which is the best minecraft server? a. mineplex b. worldonecraft c. 9b9t d. 2b2t
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Selling a product through an electronic medium is
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Stops: using the information learned in this course, explain three things you will not do when driving. a. b. c. explain why you will not do these things when driving. starts: using the information learned in this course, explain three things you will do when driving. a. b. c. explain why you will do these particular things when driving. explain one thing you will stop doing as a passenger. explain one thing you will start doing as a passenger.
Answers: 3
question
Computers and Technology, 24.06.2019 06:30
Some peer-to-peer networks have a server and some don't. true false
Answers: 2
You know the right answer?
write a program that consists of two threads. The first is the main thread that every Java applicati...
Questions
question
Mathematics, 10.11.2021 20:00
question
Mathematics, 10.11.2021 20:00
Questions on the website: 13722363