Is the WebSocket .send() method thread-safe? · Issue #491 · TooTallNate/Java-WebSocket · GitHub
Skip to content

Is the WebSocket .send() method thread-safe? #491

Description

@werner291

Hello,

suppose you implement a WebSocketServer that distributes WebSocket objects (received through onOpen) to diffferent worker threads, is it safe to call send(String...) on those from those other threads?

What about 2 threads sending in the same WebSocket?

WebSocketImpl does appear to use a BlockingQueue internally, so it should be safe, but is this safe to assume?

Also, if this is not the case, is it safe to synchronise on individual WebSocket instances, or do I have to do something special?

I tried finding something in the documentation about this, but couldn't.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions