From: Walle Wallen Date: 2011-01-15T06:39:47+09:00 Subject: Thread, locking TcpSocket from each other? I got a question regarding threads and the function gets. Lets say I got two threads running simultaneously. Both are reading from the same TCPSocket. Will the threads be able to read from the same TCPSocket at the same time, or will the first thread lock it from the other. Example code [code] def user_idle_time(connection, name, conn) Timeout::timeout(3.5) do connection.send("whois #{name} #{name} \r\n", 0) while server_response = connection.gets if(server_response.split(" ")[1].to_i == 317) return conn["Factotum"].seconds_to_hms(server_response.split(" ")[4].to_i) else @cached_messages << server_response end end end rescue Timeout::Error return "Unknown" end [/code] -- Posted via http://www.ruby-forum.com/.