threads with locking for common result