为什么我得到了如何克服这个异常来使我的程序工作正常“线程中的异常”Thread-7“java.lang.IllegalThreadStateException”

时间:2017-05-11 12:52:59

标签: java multithreading

我有class PlayTone ,其中有ThreadMP3Library来自jLayer public static class PlayTone extends Thread{ public void run() { while (true) { try { FileInputStream fis = new FileInputStream(jLabel12.getText()); Player playMP3 = new Player(fis); playMP3.play(); } catch (Exception e) { System.out.println("PLAY TONE"); //e.printStackTrace(); } } } } }。

public class PlayAlarmWhenTheTimeIsRight extends Thread {
    private volatile  boolean running = true;
    final playTOne pt = new playTOne();
    String textsOfAllLabels = jLabel4.getText() + jLabel7.getText() + " " + jLabel8.getText();
    String first = textsOfAllLabels.substring(0, 5);
    String second = textsOfAllLabels.substring(6, 9);

    final String ifTime = first + second;

    public void run() {

        while (running) {
            if (ifTime.contains(jLabel11.getText())) {

                pt.start();
            } else if(jButton4.isEnabled()==false){
                System.out.println("shutodown");
                shutdownThisThread();

            }else{

            }

        }
    }
    public void shutdownThisThread() {
        running = false;
    }

}

我还有另外一个类叫上面的 PlayTone 类。下面你可以看到那个班级

Throws

但是当我运行此程序时Exception Exception in thread "Thread-7" java.lang.IllegalThreadStateException at java.lang.Thread.start(Thread.java:705) at AlarmClock$PlayAlarmWhenTheTimeIsRight.run(AlarmClock.java:675) 如下。

USE Sunset

GO

ALTER VIEW vedere1 AS

SELECT DISTINCT c.Nume AS num_client, r.Nr_camera AS camera, 
f.Data_emiterii, f.Suma

FROM factura f, clienti c, camera r

WHERE (f.Id_client=c.Id_client) AND (r.Id_client=c.Id_client)

GO

任何人都可以告诉我我的代码有什么问题???

0 个答案:

没有答案