Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Thread procedure just claims that InterruptedException is never thrown

807605Jul 12 2007 — edited Jul 12 2007
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-
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 9 2007
Added on Jul 12 2007
6 comments
1,567 views