implement barrier synchronization