Only the read thread is assigned a name in a WebSocketClient instance. The main Runnable acquires a default name like "Thread-7". I'm working on an application where I need to identify threads and manage them, and it would be nice to be able to distinguish them purely by name instead of inspecting their stack trace.
According to oakkitten who it pointed out in this thread, the connect() method creates a writeThread field which is overwritten with a new WebsocketWriteThread when the thread runs. WebsocketWriteThread sets the name, but the thread started in the connect() method continues to run with the default name.
Additionally oakkitten noted that a new Timer is created in AbstractWebSocket and it also lacks a name.
Only the read thread is assigned a name in a
WebSocketClientinstance. The mainRunnableacquires a default name like "Thread-7". I'm working on an application where I need to identify threads and manage them, and it would be nice to be able to distinguish them purely by name instead of inspecting their stack trace.According to
oakkittenwho it pointed out in this thread, theconnect()method creates awriteThreadfield which is overwritten with a newWebsocketWriteThreadwhen the thread runs.WebsocketWriteThreadsets the name, but the thread started in theconnect()method continues to run with the default name.Additionally
oakkittennoted that a newTimeris created inAbstractWebSocketand it also lacks a name.