Added a flush mechanism to actor thread. This is used to wait for all waiting jobs in the queue to be completed.