[Haskell-beginners] Re: Interrupting a thread

Maciej Piechotka uzytkownik2 at gmail.com
Sun Dec 27 11:35:20 EST 2009

On Sat, 2009-12-26 at 23:11 -0600, Floptical Logic wrote:
> Hi,
> I am new to concurrency in Haskell and I am having trouble
> implementing the notion of interrupting a thread.
> In a new thread, call it waitNotify, I am trying to do the following:
> pop a number from a stack, wait some number of seconds based on the
> number popped from the stack, perform some notification, and repeat
> until there are no more numbers in the stack at which point we wait
> for a new number.
> These numbers will be supplied interactively by the user from main.
> When the user supplies a new number, I want to interrupt whatever
> waiting is happening in waitNotify, insert the number in the proper
> position in the current stack, and resume waitNotify using the updated
> stack.  Note, here "stack" is just a generalization; it will likely
> just be a list.
> What is the most idiomatic way to capture this sort of behavior in
> Haskell?  My two challenges are the notion of interrupting a thread,
> and sharing and updating this stack between threads (main and
> waitNotify).
> Thank you

1. Hmm. IMHO - maybe you should look on CHP. As far as I remeber
writing/reading to channel there is blocking.

2. You mean stack (FILO) or queue (FIFO)?

3. Why don't just read lazily from input? 


More information about the Beginners mailing list