DOUBLE-CHECKED LOCKING OPTIMIZATION

Reduces contention and synchronization overhead whenever critical sections must acquire locks in a thread-safe manner, just once during program execution.


if ( first_time == false ) 
{
  lock_->acquire();
  if ( first_time == false ) 
  {
    // critical section to be executed once
    first_time = true;
  }
  lock_->release();
}
Marco Corvi - Page hosted by geocities.com.