PhilipsHue / PhilipsHueSDK-Java-MultiPlatform-Android

The Software Development Kit for Philips Hue Java Mulfi-Platform and Android (beta)
273 stars 214 forks source link

PHHueSDK leaves an open thread #13

Closed chms closed 9 years ago

chms commented 9 years ago

I don't know if this is a wanted effect, but even when destroying the PHHueSDK, there remains an open thread. Consider the following Java program

import com.philips.lighting.hue.sdk.PHHueSDK;

public class Test {
    public static void main(String[] args) {
        // Create SDK
        PHHueSDK phHueSDK = PHHueSDK.create();

        // Main code
        System.out.println("Do main task");

        // Exit program
        phHueSDK.disableAllHeartbeat();
        phHueSDK.destroySDK();
    }
}

It won't exit unless you add a System.exit(0) at the end because there will be a thread [Timer-0] even after you "Clean up resources held by the SDK" through destroySDK().

SteveyO commented 9 years ago

Sorry for not replying to this earlier. I did check but forgot to post back. This issue was reported on the forum today so I posted a reply there.

http://www.developers.meethue.com/content/java-program-wont-exit-hue-sdk-active

SteveyO commented 9 years ago

The fix for this has just been committed. If you take any of the new huelocalsdk.jar files (either from the QuickStart or JavaDesktop app lib folders) then the Timer thread is now killed when calling the destroySDK method.