On 02/09/2015 12:34 PM, xtreak wrote:

> I want the stringConverter to send a message to square which in
> turn messages the main function with string "hello".

Your code did almost that but there was a bug (which I've pointed out).

> So are you saying that message is not delivered to square from
> stringWorker.

Not in your code due to that bug but the program that I've shown does exactly what you want.

> How does embedding the receive call inside the int in
> stackoverflow answer receives the message?

Once one receive() is executed, the program flow continues with further expressions. The suggestion that you received was making square() wait a second message. It need not be "embedded" at all. All it is needed was a second receive() call. That's all... However, that is not what you intended anyway.

You wanted stringConverter() to send a message to main(). So, just forget about that embeded receive and either do what my program did or fix the bug. :) (See my earlier message.)

> It seems silly but how can I keep my threads alive to receive
> messages?

By having an infinite loop like 'while (!done)'. (Please see my program.)

Ali

Reply via email to