Hello,

i'd a discussion in russian programmer's forum (rsdn.ru) about
haskell and learning it. one interesting point was that imperative
programmers imagine that multi-threading programming should require
special knowledges. they was really amazed when i showed the following
program that creates thread and interacts with it - without locks,
semaphores, synchronized access and all other old stuff

-- Thread, that cyclically read commands from channel, and executes them
graphThread c = do cmd <- getChan c
                   cmd
                   graphThread c

-- Creates graphThread and sends a few commands to it for execution
main = do c <- newChan
          forkOS $ graphThread c
          putChan c (print "Hi")
          tid <- forkOS $ putChan c (print "Hi from other thread")
          putChan c (print "Bye")
          waitThread tid

i think that some example like it would be appropriate in haskell book
for *novices* - just because it's easy to do in Haskell. so, i vote
for adding Multi-threading chapter to such books (and it may be
especially important nowadays when everyone are crazy about
multi-cores :)

-- 
Best regards,
 Bulat                          mailto:[EMAIL PROTECTED]

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to