java - Can't get System.exit() to work in dragon12 project -
i have working system.exit(0)
. should exit time remaining if button pressed. i'm not sure do. appreciated.
/* creates perfect hard-boiled(simulates 12 minutes in boiling water) or soft-boiled egg(simulates 6 minutes in boiling water). both options require 10 seconds of rinsing under cold water after necessary time boiling. allow user exit remaining time. */ import java.io.*; import java.util.*; public class advancedeggmaker { public static void main(string[] args) { mcu mcu = null; try { mcu = new mcu(new communicator(args[0])); } catch (ioexception e) { system.out.println(e); } mcu.println("sw2 - hb egg", 0); mcu.println("sw3 - sb egg", 1); while (true) { int sw = mcu.getswitch(); if (sw == 2) { mcu.println("hard boiled egg", 0); mcu.println("place egg in", 0); mcu.println("boiling water", 1); mcu.println("then press sw4", 0); mcu.println("sw5 - quit", 1); int sw2 = mcu.getswitch(); switch (sw2) { case 4: int t = 720; while (t > 0 && sw2 == 4) { t = (t - 1); mcu.println("boiling...", 0); mcu.println((t / 60) + "mins left...", 1); } break; case 5: system.exit(0); break; } } if (sw == 3) { mcu.println("soft boiled egg", 0); mcu.println("place egg in", 0); mcu.println("boiling water", 1); mcu.println("then press sw4", 0); mcu.println("sw5 - quit", 1); int sw2 = mcu.getswitch(); switch (sw2) { case 4: int t = 360; while (t > 0 && sw2 == 4) { t = (t - 1); mcu.println("boiling...", 0); mcu.println((t / 60) + "mins left...", 1); } break; case 5: system.exit(0); break; } } mcu.println("rinse egg", 0); mcu.println("then press sw4", 0); mcu.println("sw5 - quit", 1); int sw3 = mcu.getswitch(); if (sw3 == 4) { double t = 10; while (t > 0.0) { t = (t - 1); mcu.println("rinsing...", 0); mcu.println(t + "secs left...", 1); } if (sw == 5) { system.exit(0); } } } } }
are sure execution reaching 1 of system.exit(0) statements. don't see sysout or logs sure that. first examine because don't see there reason why should not work.
secondly can check whether have background thread working in code. may case may have connections/streams open somewhere in thread , not letting system.exit(0) terminate process.
Comments
Post a Comment