Thread startet nicht :-(

Status
Nicht offen für weitere Antworten.

sambalmueslie

Bekanntes Mitglied
Hallole,
ich hab mal wieder ein Problem, wo ich ein wenig ratlos bin.

Code:
public class animation implements Runnable {
    Thread runner;
    boolean run;
    int n,s;
    virtual_guitar_main gm;
    
    public animation(virtual_guitar_main gm) {
        this.gm = gm;
    }
    
    public void run()
    {
        System.out.println("Going");
        while(true)
        {
            String speed = "" + gm.opt.tempo.getValue();
            int sp = Integer.parseInt(speed);
            if(run) {
                while (gm.opt.selectedkey != gm.fb.finger_board_keys[n][s]) {
                    n++;
                    if (n > 12)
                        s++;
                    if (s > 6)
                        break;
                }
                gm.fb.curn = n;
                gm.fb.curs = s;
                gm.fb.repaint();
                try {
                    Thread.sleep(60000 / sp);
                } catch (InterruptedException e) {}
            }
            System.out.println("n:" + n + " s:" + s);
        }
    }
    public void playAnimation()
    {       
        run = true;   
        n=0;
        s=0;
        gm.opt.running.setText("Stop");
        System.out.println("Go");
        runner = new Thread();
        runner.start();
     }

     public void stopAnimation()
     {       
         run = false;   
         runner = null;
         gm.opt.running.setText("Go");
         System.out.println("Halt");
      }


}

Wenn ich jetzt playAnimation() aufrufe, dann startet der "runner" irgendwie nicht. (Going wird nicht ausgegeben)
Hat jemand eine Idee warum??
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben