File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
TimeNETOptimizationEnvironment/src/toe/simulation Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -259,15 +259,12 @@ private void startLocalSimulation(String exportFileName) {
259259
260260 // Start new process
261261 timeStamp = Calendar .getInstance ().getTimeInMillis ();
262-
263262 nativeProcess myNativeProcess = new nativeProcess (processBuilder , this );
264-
265- //We wait until the process is ended or aborted
266- //TODO: Use thread synchronization with timeout!
267- while (myNativeProcess .isRunning ()) {
268- Thread .sleep (500 );
269- if ((Calendar .getInstance ().getTimeInMillis () - timeStamp ) / 1000 >= maxTime ) {
270- support .log ("Simulation took longer than given MaxTime! Will be aborted! " + " MaxTime was:" + maxTime .toString (), typeOfLogLevel .ERROR );
263+ synchronized (myNativeProcess ) {
264+ try {
265+ myNativeProcess .wait (maxTime * 1000 );
266+ } catch (Exception e ) {
267+ support .log ("Simulation may took longer than given MaxTime! Will be aborted! " + " MaxTime was:" + maxTime .toString (), typeOfLogLevel .ERROR );
271268 myNativeProcess .setKillProcess (true );
272269 }
273270 }
You can’t perform that action at this time.
0 commit comments