Skip to content

JVM does not exit after a simple script using this lib #6

@Stewori

Description

@Stewori

Whenever I run a script with this lib, the JVM is "hanging" when the script is done, even if the script does not contain an event loop of any kind. At least after closing the last device with

		status = dev.stopApplication(receiver, true);
		dev.disconnect();

I would expect all is set for a normal JVM termination. To find out what's going on I added this code snippet (jstat might have done it as well)

		Set<Thread> threads = Thread.getAllStackTraces().keySet();
		System.out.printf("%-15s \t %-15s \t %-15s \t %s\n", "Name", "State", "Priority", "isDaemon");
		for (Thread t : threads) {
			System.out.printf("%-15s \t %-15s \t %-15d \t %s\n",
					t.getName(), t.getState(), t.getPriority(), t.isDaemon());
		}

This results in:

Name            	 State           	 Priority        	 isDaemon
Finalizer       	 WAITING         	 8               	 true
Notification Thread  RUNNABLE        	 9               	 true
main            	 RUNNABLE        	 5               	 false
Cast API worker #1 	 TIMED_WAITING   	 5               	 false
Signal Dispatcher 	 RUNNABLE        	 9               	 true
Common-Cleaner  	 TIMED_WAITING   	 8               	 true
Reference Handler 	 RUNNABLE        	 10              	 true
Cast API worker #2 	 TIMED_WAITING   	 5               	 false

Maybe the Cast API worker threads could be daemons? Or, if that causes trouble elsewhere, there could be some shutdown method that turns them into daemons? I'd think disconnect(); should do this, but maybe that's a problem if multiple devices are controlled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions