Hi everyone,
Take a look at the following code block.
->Class InterruptionDialog
public class InterruptionDialog extends JDialog
{
//Fields
Thread currentThread;
JButton interruptionButton;
//Constructor
public InterruptionDialog(JFrame parent, boolean modal, Thread t)
{
super(parent, modal);
currentThread = t;
interruptionButton = new JButton("Click to interrupt");
interruptionButton.addActionListener( new ActionListener(){
public void ActionPerformed(Event evt) {
<????>
}});
}
}
-> Class MyClass
public class MyClass
{
//Fields
Thread executionThread;
....
public void criticalMethod()
{
executionThread = new Thread( new Runnable(){
public void run(){
InterruptionDialog d = new InterruptionDialog(null, false, executionThread);
javax.swing.SwingUtilities.invokeLater( new Runnable(){ public void run(){
d.setVisible(true); }});
<STUFF HERE....>
}});
executionThread.start();
try{
executionTread.join();
}
catch(Exception e){}
<STUFF HERE....>
}
}
Where <????> is placed I want to stop the thread's execution upon user's request. I' ve used method t.stop(), which worked fine, but is deprecated. Is there any "non- deprecated" way to stop the execution of the Thread through the InterruptionDialog? I've read Sun's instructions but I haven't got anything useful out of it (or obviously I am as smart to understand it!). I would gladly provide more information if needed.
Thank you in advance,
F.