views:

51

answers:

2

Hello to all, i wonder what the difference between these two ?

Thanks.

A: 

Message Queue is used for (asynchronous) inter-process communication while a Thread Pool us used to run multiple tasks on a set of threads. I can't think of a reasonable way to compare them... they're fundamentally different from each-other in so many ways.

Lirik
Thanks for your explanation.
peterwkc
+1  A: 

The real question would be whether there's any similarity between the two. A message queue is a data structure for holding messages from the time they're sent until the time the receiver retrieves and acts on them.

A thread pool is a pool of threads that do some sort of processing. A thread pool will normally have some sort of thread-safe queue attached to allow you to queue up jobs to be done. This would more often be called something like a "task queue" than a message queue, though it will normally contain some sort of messages that describe the tasks that need to be done.

Jerry Coffin
Thanks for your explanation.
peterwkc
I wonder does the message queue enforce the sender and receiver must came from different process or thread.
peterwkc
@peterwkc: every message queue I've seen allows a thread to post a message back to itself.
Jerry Coffin
It does make sense for me at least to post a message back to itself. Please clarify with example.
peterwkc
@peterwkc: one example would be a window for something like a test that has a timer running so when the window first shows, it has (say) 60 seconds remaining for you to fill in the blanks. When it's first displayed, it sets a timer to have a message posted back to itself once a second to update the timer, and after 60 seconds, tell you that you've run out of time.
Jerry Coffin
@Jerry Coffin: Good example. Thanks for your example.
peterwkc