[MLton-devel] MLton Threads

Stephen Weeks MLton@mlton.org
Thu, 1 May 2003 13:48:55 -0700


Hi Christopher.

> However, I haven't been able to switch back to a thread that
> was once running---I get the error message "Failed switch to a dead
> thread."  Can you tell me how a thread becomes designated as "dead," and
> how I can avoid this?

The problem stems from the fact that you can only switch to a thread
once (this sounds weird but hopefully it will make sense in a sec).
When you switch to a thread, the thread is marked Dead and starts
running.  If you want to switch to the thread again, you need to grab
that running thread either via Thread.switch or a signal handler,
which will create a new thread object that can be switched to (once).

There are examples of both cooperative and
preemptive multi-tasking that come with the MLton documentation.  See

	/usr/share/doc/mlton/examples/thread{1,2}.sml

Have a look at those and if you still have questions, feel free to
send them.


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel