From: Larry Sachs Date: Mon, 10 Oct 2016 21:21:13 +0000 (-0700) Subject: Keep SimpleServer Alive X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=18d2c3297c94b6bdb179270c97327187eb1a7945;p=contrib%2Fiotivity.git Keep SimpleServer Alive Change-Id: Ia91714e660546de5c1b0002956475f03b1e0f1d1 Signed-off-by: Larry Sachs Reviewed-on: https://gerrit.iotivity.org/gerrit/13053 Tested-by: jenkins-iotivity Reviewed-by: Rick Bell --- diff --git a/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java b/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java index a5c2883..446fb8a 100644 --- a/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java +++ b/java/examples-java/simpleserver/src/main/java/org/iotivity/base/examples/SimpleServer.java @@ -107,10 +107,19 @@ public class SimpleServer { private final static String TAG = SimpleServer.class.getSimpleName(); public static void main(String[] args) { + Runtime.getRuntime().addShutdownHook(new Thread() { + public void run() { + stopSimpleServer(); + } + }); + startSimpleServer(); + while (true) { + sleep(1); + } } - public void sleep(int seconds) { + public static void sleep(int seconds) { try { Thread.sleep(seconds * 1000); } catch (InterruptedException e) {