in reply to SSH by thread

Based on nothing more than the little you've said in your post -- ie. no first hand experience whatsoever -- it sounds like the library you are using is not thread-safe.

So, as you say "if I run it in main,it runs well.", why bother trying to run it in a thread?

That is to say, if you need to do other stuff concurrently, run that other stuff in the thread, and leave this bit to run in main.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^2: SSH by thread
by Anonymous Monk on May 14, 2015 at 19:51 UTC
    Indeed. Probably lotsa globals here. If you need to run multiple parallel SSH connections, consider using processes, not threads.