Making parent thread invoke a method from the child thread

Merry Christmas Everyone!

I have a child thread invoked by juce to do some background work. When that work is finished I need to have the parent thread invoke a function with the status. Today, I need the method in parent which created this child to hang around, until the child thread is done and invoke the method based on value stored in a location. But I need this parent method to return as soon as it creates the child method.

Is there an easy way for the child thread’s run method to get the parent to invoke a method? Can I pass an arg to this thread constructor, like a reference to the parent thread which can then be used to invoke such a method?

I know there are better ways of doing this like setting up a better communication architecture but that would be an overkill in my case. I just want the activity to happen in the background so that the original parent method can return back to its caller without hitting a timeout.

As long as you’re positive the first thread can’t possibly be deleted while the second thread is still running, then there’s no reason why you couldn’t start the background process with a callback pointer to the first. You’ll be somewhat tightly coupling the classes though, so you’re still probably going to want to make at least a lightweight messaging system.