Question
JAVA PROGRAMMING You are required to create a main class to apply ExecuterService with SingleThreadExecuter. The variable i is integer number and MUST be input
JAVA PROGRAMMING
You are required to create a main class to apply ExecuterService with SingleThreadExecuter.
The variable i is integer number and MUST be input from the keyboard.
Output should be like this:
Please input i: 3
pool-1-thread-1: 1
pool-3-thread-1: 1
pool-3-thread-1: 2
pool-3-thread-1: 3
pool-2-thread-1: 1
pool-2-thread-1: 2
pool-2-thread-1: 3
pool-1-thread-1: 2
pool-1-thread-1: 3
Total = 9 Below is the part of code. class Counter
public class Counter
{ | |
private int counter; | |
public void increment(){ | |
counter++; | |
} | |
public void decrement(){ | |
counter--; | |
} | |
synchronized public void myIncrement(){ | |
counter++; | |
} | |
synchronized public void myDecrement(){ | |
counter--; | |
} | |
} |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started