in reply to Re^4: Execute a sub in the background
in thread Execute a sub in the background
If you start a thread (->create()) and then immediately wait for it to finish (->join), that is the same as not starting a thread at all.
If you are not interested in the result of the thread, you should detach it.
The simplest way of doing what I think you are trying to achieve with your snippet above is:
async( \&status_line )->detach;
Notice there are no parens () after the name of the sub to be run asynchronously.
What you have above should have produced several error messages, because you are calling the sub status_line() then attempting to take a reference to its return value, and then pass that as the code reference to the thread, which obviously won't work.
|
|---|