beam: thread-safe receiving and sending