in reply to How do you share an object(Telnet Session) between threads?
I need the Telnet session below available to 3 threads(connect, disconnect, & scan).
What is the purpose of sharing one session between 3 threads?
The reasoning behind my question:
then their communications will all interfere with each other and the remote session will just become corrupted and fail.
Then it make no sense to share the telnet session; you'd just be making life hard for yourself.
Far better to start a fourth thread that has a input queue.
Have the three threads queue the information required to perform their requests; the fourth thread issues the request via its single, unshared telnet session; and then return the results to the calling thread.
The serialisation is automatic and efficient; and you avoid all the complications and risks of sharing a complex object.
That said; telnet servers are designed to host multiple sessions. The simplest solution would be to have each of your threads starts its own unshared session to the remote telnet server and let it do what it is designed to do.
If you have a reason not covered by the above for wanting to share a single telnet session; please identify it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How do you share an object(Telnet Session) between threads?
by jmlynesjr (Deacon) on Sep 29, 2015 at 19:34 UTC |