1package com.gams.examples.interrupt;
4import java.io.PrintStream;
22 public static void main(String[] args) {
24 boolean interactive =
false;
25 if (args.length > 0) {
27 if (args.length > 1) {
28 interactive = args[1].equals(
"interactive") ? true :
false;
32 File workingDirectory =
new File(System.getProperty(
"user.dir"),
"ConsoleInterrupt");
33 workingDirectory.mkdir();
43 final Worker w =
new Worker(job, opt, System.out);
48 Runtime.getRuntime().addShutdownHook(
new Thread() {
52 boolean terminated = (w.getState()==Thread.State.TERMINATED);
53 boolean interrupted =
false;
56 System.out.println(
"*** job: " + job.
getJobName() +
" finished in interactive mode "
57 + (terminated ?
"without interruption : " :
" with interruption : " )
65 Thread.currentThread();
67 catch ( Exception e ) {
72 boolean terminated = (w.getState()==Thread.State.TERMINATED);
73 boolean interrupted =
false;
76 System.out.println(
"*** job: " + job.
getJobName()+
" finished in non-interactive mode "
77 + (interrupted ?
"with " :
"without ")
78 +
"interrut signal sent."
84 static class Worker
extends Thread {
94 public Worker(
GAMSJob jb,
GAMSOptions opt, PrintStream out) { job = jb; option = opt; output = out; }
100 job.
run(option, output);
101 }
catch(Exception e) {
void setAllModelTypes(String value)
void setSystemDirectory(String directory)
void setWorkingDirectory(String directory)
GAMSJob addJobFromGamsLib(String modelName)
This example demonstrates how to interrupt a solve in a running job but then continues with the execu...
Provides package namespace for Java interface and examples to General Algebraic Model System (GAMS).