# Monitor#synchronize and Thread#wakeup

**URL:** <https://www.ruby-forum.com/t/monitor-synchronize-and-thread-wakeup/54595>\
**Category:** Development\
**Created:** [March 9, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/monitor-synchronize-and-thread-wakeup/54595 "2006-03-09T16:11:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![URABE\_Shyouhei\_aka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/e47c2d/32.png) [@URABE\_Shyouhei\_aka](https://www.ruby-forum.com/u/URABE_Shyouhei_aka)\
**Post date:** [March 9, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/monitor-synchronize-and-thread-wakeup/54595/1 "2006-03-09T16:11:30Z")

</div>

e$BKNIt$G$9!#e(B

e$B0J2\<$N%9%/%j%W%H$r\<B9T$9$k$H!"\<j85$G$Oe(Bt2e$B$N%k!\<%We(B  
e$B$,0l2s$7$+2s$i$J$$$N$G$9$,!"0U?^$5$l$?5sF0$J$s$Ge(B  
e$B$7$g$&$+e(B?  
"loop { t1.wakeup }“e$B$N9T$r%3%a%s%H%”%&%H$9$l$P!"e(B  
e$B$A$c$s$HKhICe(Bt2e$B$,F0$$$F$k$3$H$r4QB,$G$-$k$N$G$9$,!#e(B

require “monitor”  
extend MonitorMixin

def x(n)  
synchronize do  
x(n-1) unless n.zero?  
end  
end

t1 = Thread.start do  
i = 0  
loop do  
x(i)  
i += 1  
end  
end

t2 = Thread.start do  
loop do  
synchronize do  
sleep 1  
p Time.now  
end  
end  
end

loop { t1.wakeup }  
sleep
