How to set a deadline and get notified when the time is over?