Question: Edit the main method so that the Counters now try to count from 0 to 10,and from 10 to 0, in steps of1. Make sure
Edit the main method so that the Counters now try to count from 0 to 10,and from 10 to 0, in steps of1. Make sure that the Counters trace their behaviour. Run this revised method a number of times, and answer the following questions. Make sure that you explain your answers.1. Will the test always terminate? I.e. is it certain that no matter how often you were to run the test it would always end in a finite length of time?2. What is the shortest possible output for the test, in terms of the number of lines output?What is the largest possible value that the count can reach when the testis run?4. What is the lowest possible value that the count can reach when the testis run?
package counter;
/** * A demonstration of the use and behaviour of Counters and ThreadSets. */ public class Main { /** * Demonstrate the behaviour of counters and ThreadSets. A thread set is populated with two counters, and * the thread set's runSet method is used to run the counters concurrently. * * @param args not used * @throws CounterException should not occur * @throws InterruptedException should not occur */ public static void main(String[] args) throws CounterException, InterruptedException { /* * Create two counters (in a thread set), and then run them with tracing on, so that their * behaviour is visible. */ ThreadSet
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
