BridgesUNCC / bridges-java

JAVA Client library for Bridges
http://bridgesuncc.github.io
GNU General Public License v2.0
4 stars 12 forks source link

Java thread lingers with games #160

Open AlecGoncharow opened 4 years ago

AlecGoncharow commented 4 years ago

https://github.com/BridgesUNCC/bridges-java/blob/6c8ee5e0805c99715ee78d0588e8a622313eab15/src/main/java/bridges/games/NonBlockingGame.java#L232

https://stackoverflow.com/questions/1611931/catching-ctrlc-in-java

AlecGoncharow commented 4 years ago
Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            try {
                Thread.sleep(200);
                System.out.println("Shutting down ...");
                //some cleaning up code...

            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                e.printStackTrace();
            }
        }
    });
AlecGoncharow commented 4 years ago

18b7c47188a5053d61f8bca1c40dff5c95100df0 Should help addressing this issue. Without the runtime shutdown hook it seemed like the terminateNetwork() function was never actually being hit.