You can adjust the "thread" even more flexible with "hooks". It is a few methods in AzaThread, which are called in a variety of situations. And you can override them to perform any special functionality.
class ExampleThread extends Thread
{
function process()
{
// ...
}
protected function onLoad()
{
// ...
}
}Hook called after thread initialization, but BEFORE forking!
Hook called after thread forking (only in child process). Use this if you need to initialize something in child process and do it only once.
It's already called after initialization in synchronous fallback mode!
Hook called before shutdown (only in child process). Use it if you need to do something before the end of the child process.
Called in child and parent processes during the full resources cleanup. Use it if you need to close/cleanup something.