Thread procedure just claims that InterruptedException is never thrown
Hello!
I have a simple thread procedure that persitantly gives errors about not throwing InterruptedExceptions.
exception java.lang.InterruptedException is never thrown in body of correspondingtry statement
I have tried to addcatch statements andthrows InterruptedException definitions to my code into several places without success.
Please, I would highly appreciate if you could point me in detail all the rows in my code where I should put some new statements and definitions.I have already tried to add throws InterruptedException definitions to all methods that are "above" the method that calls ThreadAccess class. But still the original error message appears.
Here are the main parts of my code (without some method between main and mouseClickedOnCorrectJPanel):
privatestaticclass ThreadActionimplements Runnable{
publicvoid run(){
try{
animateJPanel();
}catch (InterruptedException e){
System.out.println("Error message");
}
}
}
...
privatevoid mouseClickedOnCorrectJPanel(){
try{
startingTime = System.currentTimeMillis();
Thread t =new Thread(new ThreadAction());
t.start();
while (t.isAlive()){
t.join(timeIntervalForCheckingIsThreadStillAlive);
if (((System.currentTime() - startingTime) > patientWaitingTimeForThread) && t.isAlive()){
t.interrupt();
t.join();
}
}
playMusic();
}catch (InterruptedException e){
System.out.println("interrupt. exception ilmestyi");
}
}
...
class MyApplication
{
publicstaticvoid main(String[] args)throws IOException{
try{
JFrame frame =new JFrame("MyApplication");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
SwingApplication app =new SwingApplication();
app.addComponentToPane(frame.getContentPane());
frame.pack();
frame.setVisible(true);
}
finally{
System.out.println("Finished");
}
}
}
Thank you for helping!!
-Wonderful-

