Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread behave differently and stop on some machines??  RSS feed

 
Praveen Kumar Jayaram
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am developing a Java Swing application, which launches an external exe.
Then I am using a Thread to monitor whether the launched exe is running or terminated abruptly by using its PID. If it terminates then the thread shows a msg box.
Everything works fine in my machine and in few other machines.

But the same thread stop abruptly on some other machines... and displays the msg box even though the exe is running correctly.
And I heard thread behaves differently on different CPUs'.

How to handle this situation??
Please help.

This is my code:

public class SolverPoller implements Runnable
{
String solver = null;
int PID;

/**
* Constructor to initialise the Thread
* @param programName - Solver execuatable name
* @param pid - Process ID of the running solver
*/
SolverPoller(String programName, int pid)
{
solver = programName;
PID = pid;

//reset the blnClosedAbruptly
blnClosedAbruptly = false;
}

public void run()
{
File deleteFile = null;
try
{
//if the stored PID and refreshed are same
//Continue waiting
while(checkPIDOfSolver(String.valueOf(PID), solver))
{
//sleep for a sec
Thread.sleep(1000);
}
//When the solver process terminates
//interrupt ProgressBarIncrementer Thread
inc.interrupt();

if(Delia.getProcessorType() == 'T')
deleteFile = new File("TIP3DSolver.res");
else if(Delia.getProcessorType() == 'S')
deleteFile = new File("SPLITVISSolver.res");

if(!deleteFile.exists())
{
//set it to true, indicating solver terminated abruptly
blnClosedAbruptly = true;
progressBar.setValue(0);
progressBar.setStringPainted(true);
progressBar.setString("0%");
progressBar.repaint();
JOptionPane.showMessageDialog(DentonIntegratedToolApp.getDentonInstance().getFrame().getContentPane(), "Solver terminated abruptly!", "Solver Error", JOptionPane.ERROR_MESSAGE);
}
}
catch(InterruptedException ie)
{}
catch(Exception e)
{}
finally
{
deleteFile = null;
}
}
}
[ August 21, 2008: Message edited by: Praveen Kumar Jayaram ]
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the code posted, I have no idea what "checkPIDOfSolver", "Delia.getProcessorType()", or how you originally get the PID - all of which would impact why this code does (or doesn't) work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!