handle pause/resume. new thread makes it a bit complicated.