in reply to How do you share an object(Telnet Session) between threads?
As BrowserUK ably suggests, when a thread is dedicated to the care-and-feeding of any external resource or host connection, it can be reliably programmed to deal with any eventuality, and to always know the state of that connection. Even if you decided to open multiple telnet sessions, I would still have a controller-thread (instance ...) dedicated to each one, which accepted requests and delivered results using thread-safe queues. A finite-state machine (FSM) is an excellent design for this piece. A second queue can be used to communicate status to the parent thread, analogous to the separate STDERR output-stream of an ordinary Unix process.
| Replies are listed 'Best First'. |
|---|