The code in the book has a small error (see the errata at http://www.inf.puc-rio.br/~roberto/book/errata1.html). You can get the correct code at http://www.inf.puc-rio.br/~roberto/book/code/multithread.lua.html (I hope this one works...). -- Roberto