Advertisement
abrar1

Untitled

Jun 23rd, 2023
779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 KB | None | 0 0
  1.  
  2. class SharedCounter {
  3.     private int counter ;
  4.  
  5.     SharedCounter(){
  6.         this.counter = 0 ;
  7.     }
  8.  
  9.     private void increment(){
  10.         this.counter++ ;
  11.     }
  12.  
  13.     public int get(){
  14.         return this.counter;
  15.     }
  16.  
  17.     public void count (){
  18.  
  19.         for (int i = 0 ; i <= 1000 ; i++){
  20.             increment();
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement