Question: Write a PingPong class in Java using netbean IDE that implements the Runnable interface and will write ping or pong in a console window. Have

Write a PingPong class in Java using netbean IDE that implements the Runnable interface and will write ping or pong in a console window. Have it print the word (ping or pong) at least 10 times before it terminates.

Write a program that creates and runs two threads using the PingPong class. One that prints ping, one that prints pong.

Additional Notes:

The PingPong class should print ping or pong only. It should not even be able to print anything else. You can use the constructor to set up which it prints (ping or pong).

Use a loop in the PingPong class to print at least 10 times and have the thread sleep for at least 10 seconds each time through the loop.

The main program should create and run two instances of the PingPong class, one that does ping and one that does pong. Comments in code appreciated!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!