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 corresponding try statement
I have tried to add
catch statements and
throws 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):
private static class ThreadAction implements Runnable {
public void run() {
try {
animateJPanel();
} catch (InterruptedException e) {
System.out.println("Error message");
}
}
}
...
private void 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
{
public static void 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-