use wait/notify mechanism