All you really need to do is wrap the TSocket, Transport, and Protocol into your own MyConnection class and have 1 per thread. There is nothing inefficient about it, except maybe a bit more memory. Or you can put a lock around your service and make it so only 1 thread can talk at any given time.
-Matt On 09/08/12 07:00, Akshat Aranya wrote:
Hi, I'm trying to implement a Thrift client and server where both are multi-threaded. Things are working fine on the server side, but I'm getting "out of sequence" errors on the client. I looked through the code a little bit, and I realized that a synchronous client can only have one outstanding message, so it is not possible to have multiple clients make simultaneous calls. This problem happens even when each thread has its own Client, but they share a Protocol. Is my assessment correct? If so, is the only way to make it work in a multi-threaded environment is to use an independent connection (i.e., a new Transport) per thread? That seems kind of wasteful and inefficient. Thanks, Akshat
