The following is an informal description, please don't take it as ground truth...
So @async will start a job and return, without waiting for the result of that job being available. So, in the code above, the real work is being done in the remotecall_fetch, which runs a function "f" in the remote process. Due to the @async, the "while true" loop will continue as soon as the function is sent to the remote process, without waiting for its result to be passed back.
When the "while true" loop is completed, you dont then want to return out of the "pmap" function, since the remote functions may not yet have finished. At that point, you want to wait till all the jobs that you have started do finish. That is what @sync does. It waits for all @async jobs to have finished before continuing. Hence, you will typically (though not always) see @sync/@async pairs.
Hope that helps.
Regards
-
Avik