Question: Using System. ThreadingSee the name an able in the object with the name you were passed. Set the time variable to your Random Object's Next
Using System. ThreadingSee the name an able in the object with the name you were passed. Set the time variable to your Random Object's Next Create a method Run with no parameters Print out My name is X I am going to sleep for Yms X should be the objects name, Y should be the time you randomly chose. Call Thread.Sleeptime;Print out My name is X I am awake, feed me"You will need to wrap the contents of your run method in a trycatch block, catching Thread Interrupted Exception. In your main class's main method, do the following: Create babies as follows: Baby bl new BabyNoah; Repeat this for b b b b They should be named Noah, Olivia, Liam, Emma, Amelia. Create threads as follows: Thread t new ThreadbRun; Repeat this for t t t and t Start all babies with a statement like tI Start;"Sample Output:My name is Noah and I am going to sleep for ms My name is Olivia and I am going to sleep for ms My name is Amelia and I am going to sleep for ms My name is Emma and I am going to sleep for ms My name is Liam and I am going to sleep for ms My name is Amelia and Im awake, feed meMy name is Olivia and Im awake, feed meMy name is Liam and Im awake, feed meMy name Moan and Im awake, teed me
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
