I have a webpage, which will be creating a buch of multithreaded calls before page contents are returned to the end user. The content of this php page are NOT dependent on the threads that it creates . The content of the page can (and most likely will) finish before the threads are finished
Here is a pseudo code
<?php
// Step 1: Start php multithreading
// CODE HERE (will probably take 20 seconds to finish)
// Step 2: Do other stuff and return the php page, mostly static things using html
// CODE HERE (will probably take 1 second to return)
?>
Now, if you look closely, the web page will still be "loading" until the code of step 1 above is finished (i.e., the page will show a rotating icon on the web browser until it is completely finished), which is about 20 seconds.
Moreover, if the webpage is closed, the script in step 1 is terminated halfway.
Now, I would like to do the following:
How to make the thread of step 1 independent of the page? i.e, if the page is closed, the thread keeps running.
Also, since the thread of step 1 is independent of the page, I want the page to finish loading once the content of step 2 are done, without waiting for step 1 to finish.
Thanks.
Update
I am thinking this might be possible via a php script invoking another php script, but not sure how.