refactor thread mailbox