java - Synchronized does not work by cyclic barrier -


public class test {      final int counter = 0; // may different number     int add = 0;      public synchronized void testsync() throws interruptedexception {         add++;         if (add == counter) {             add = 0;              notifyall();         } else {             while (add > 0) {                  wait();             }         }      } } 

how can fix code make work?i need make work cyclic barrier.

public class test {     final int counter = 0; // may different number     final cyclicbarrier barrier = new cyclicbarrier(counter);      public void testsync() throws interruptedexception, brokenbarrierexception {         barrier.await();     } } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -