I have developed a very simple websocket server to test that.
I connect to the server and then a websocket handler instance is created; it calls a simple routine of a code module which logs the CurrentThreadIndex, then I disconnect.
There is nothing else, let alone there are references to the instance of that websocket handler.
I connected the client about 29 minutes after and the CurrentThreadIndex is increased (I don't know how to get the number of currently active threads, so I use CurrentThreadIndex).
Case#1:
Assumption#1: Using Windows for "server"
Assumption#2: JDK installed on the same Windows machine
1) Start the server application
2) Go where the JDK is installed (example: C:\Program Files\Java\jdk1.8.0_92), go into the bin directory and start jconsole
3) Pick your server (it should show up in the "Local Process:" list)
4) Connect insecurely
5) Go to the threads tab and watch it as the clients connect/disconnect.
Case#2:
Assumption#1: Using Linux for server
Assumption#2: Using a Windows machine to monitor server application running on linux
Assumption#3: the JDK is installed on the Windows machine used for monitoring
It's a tad more complicated, but these links may help
http://stackoverflow.com/questions/1922290/how-to-get-the-number-of-threads-in-a-java-process and
http://stackoverflow.com/questions/834581/remote-jmx-connection.
http://stackoverflow.com/questions/834581/remote-jmx-connection
In my case, I started a server on Linux via:
java -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx \
-Dcom.sun.management.jmxremote.port=54444 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar CloudKVS_Server.jar 51043
Note#1: replace the xxx.xxx.xxx.xxx with the external IP address of the server (not 127.0.0.1)
Note#2: I did not use nohup to start it since I'm just playing here.
Then use the jconsole on the Windows machine to connect to the Linux machine and observe.