how can i achieve this behaviour?

lockhere(); // this call should not block the first thread, but any that follows. this can be achieved using a simple Lock.
if (iAmTheFirstThread)
   preparedResult = doLogic(); // may take a while
   unlockAllWaitingThreads(); // all waiting threads should be notified and immediately return the prepared result, no need for any locking
   return preparedResult;
} else {
   return preparedResult;