java - Timer.schedule() leaves an open thread after execution -


i'm trying use timer.schedule() schedule operation happen 1s after. problem i'm having after operation executed, there's open thread left hanging , i'm forced ctrl+c close it.

am doing wrong? how stop timer leaving open thread?

public class myclass {    public static int waiting_window = 1000;    private boolean waiting = true;    public myclass() {}    public void mymethod() {      new timer().schedule(       new timertask() {         @override         public void run() {           setwaiting(false);         }       }, waiting_window     );   }    public void setwaiting(boolean waiting) {     this.waiting = waiting;   } } 

keep reference timer , call timer.cancel(). , read javadocs, it's documented there!


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -