I started on Ruby less than a week ago but have already come to
appreciate the power of the language. I am trying my hands on a classic
producer-consumer problem, implemented as an Orange tree (c.f.
http://pine.fm/LearnToProgram/?Chapter=09). The Orange tree grows each
year until it dies and produces a random number of Oranges each year
(Producer). Oranges can be picked as long there are any on the tree
I’ve got two problems here:
The attached code gives me the following exception:
warning: instance variable @orange_tree not initialized
<class:Worker>': undefined methodage’ for nil:NilClass
I am not sure that the multithreading part is correctly coded.
Any help is very much appreciated. I’ve got myself a couple of books,
including “Programming Ruby” and “The Ruby P.ming Language” but
none of them contain a true “producer-consumer problem”.