# Thread dead lock/fatal

**URL:** <https://www.ruby-forum.com/t/thread-dead-lock-fatal/84065>\
**Category:** Ruby\
**Created:** [February 1, 2007, 12:05am UTC](https://www.ruby-forum.com/t/thread-dead-lock-fatal/84065 "2007-02-01T00:05:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phy\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@Phy\_P](https://www.ruby-forum.com/u/Phy_P)\
**Post date:** [February 1, 2007, 12:05am UTC](https://www.ruby-forum.com/t/thread-dead-lock-fatal/84065/1 "2007-02-01T00:05:18Z")

</div>

Hello,

I am using 1.8.5p20 (Dec 2006) of ruby using the pickaxe book example of  
extending GServer and I have come across a fatal that is perhaps my  
fault. I run the example code (below) on RHEE30 x86\_64 (ruby is 32b)  
connecting to the server instance on the same machine through a repeat  
command, as in:

repeat 100 telnet localhost 2000

I eventually get this:

[Wed Jan 31 14:52:05 2007] TimeServer 127.0.0.1:2000 client:50838  
disconnect  
deadlock 0x2a95ceafa8: sleep:J(0x2a95e514c8) (main) -  
/lan/rc/tools/1.4/lnx64b24c23/ruby185/lib/ruby/1.8/gserver.rb:128  
deadlock 0x2a95e514c8: sleep:- -  
/lan/rc/tools/1.4/lnx64b24c23/ruby185/lib/ruby/1.8/thread.rb:203  
[Wed Jan 31 14:52:05 2007] TimeServer 127.0.0.1:2000 stop  
/lan/rc/tools/1.4/lnx64b24c23/ruby185/lib/ruby/1.8/gserver.rb:208:in  
`join’: Thread(0x2a95e1f298): deadlock (fatal)  
from ./testserv.rb:22

Does this look like I am doing something wrong?

Here is the code:

cat testserv.rb  
#!/usr/bin/env ruby

require ‘gserver’  
require ‘time’

class TimeServer \< GServer  
def initialize  
super(2000)  
@count = 3  
end  
def server(client)  
client.puts Time.now.to\_s  
@count -=1  
stop if @count.zero?  
end  
end

server = TimeServer.new

server.audit = true  
server.start  
server.join

Thanks for the help!  
Phy
