From: Brian Candler Date: 2012-10-09T02:09:35+09:00 Subject: Re: Multithread in DRb ajay paswan wrote in post #1078978: > Suppose I want to create 6 threads in client side > following: http://segment7.net/projects/ruby/drb/introduction.html > > which one is better at cleint side? The second appears to be broken: 1. It calls DRb.start_service 6 times 2. It calls ARGV.shift 6 times - unless your intention is to have 6 different DRB URLs, so that you are talking to six *diffferent* remote arrays, and push one item onto each? Then that's something completely different. > To point out whats in my mind, in the later program I am getting a new > instance of the remote object, so it will not have any resource > conflict. DRb gives absolutely zero locking. If two clients make concurrent accesses to the same remote object, then they will cause concurrent method calls to execute at the server side. Tthat is, your server object *must* be thread-safe. It does not matter if you make one local proxy object and invoke it from six threads, or six separate proxy objects onto the same remote object invoked from six threads. DRb is effectively transparent to all this. If your program works correctly with six local threads accessing a single local object concurrently, then it will be fine with six threads accessing a single remote object over DRb. -- Posted via http://www.ruby-forum.com/.