primitive thread communication in practice

Threads can share any data in may ways, but there are some standard patterns to send primitive signals to each other, without any content. These are simple techniques, widely used, battle tested.

* wait/notify [3] – general purpose
* interrupt [1] [3]
* boolean done flag [1]
* join [3]

How about swing?

java.util.concurrent offers a few communication devices. These are not primitive.

[1] these are the 2 standard ways to inform [2] a thread stop itself. See the Thread.stop() api

[2] from outside the thread ie another thread.

[3] These techniques cause the receiving thread to act immediately. Shared-data techniques need the receiving thread to poll the shared data.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s