= Pitfalls = == Mutable variables sharing == With coThreads, any thing immutable is shared by default, but mutable variables, as far as you want to mutate/read them from different threads, should **always** be shared as transactional variables. It's easier to understand the principle if you know the fact that, in OCaml * VM threads share every mutable variable without protection * system threads achieve the same effect by execution over the same copy of memory, but this can hardly considered as a good way * the process (or networker) threads is implemented on independent processes which doesn't share mutable storage at all. We have no way to achieve the same effect without modifying OCaml compiler or doing sophisticated pre-processing, which is unacceptable. So with process/networker engine, the only way to share memory is through STM, which is also the precondition to achieve the semantic consistency among different engines. This is basically a good thing --- since you should anyway protect the shared accessing to a mutable variable by certain means (such as a lock), why not using STM instead? It's more concise, safe and expressive. On the other hand, there's no hard-wired restriction that you must declaring mutable variables though STM, just as there's nothing stopping you from leave a mutable variable unprotected with a traditional lock. However, by doing so, you're on your own.