Skip to content

Threads

20080528 (2008 May 28 Wednesday)

Threads are dangerous. It is difficult to communicate between threads in a safe way.

Therefore:

Avoid threads unless you have very good language support (e.g. erlang, scoop , posix pipes), except:

  • Fixing interfaces to conform to the blocking interface rule. Then fix at source e.g. threads at io boundaries.
  • Independent threads (no syncronization).

Use one of these safe models of interthread communication:

  • pipes(like Posix), thread safe queues.
  • message passing (like Erlang)
  • transactions (like Scoop)

Don’t use {semaphores, mutexes, monitors} except to implement a safe model of interthread communication.

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: