Replaced signal with signalAll to handle N-threads