--- title: Workers permalink: /workers --- ## `Worker` `Worker` provides a simple interface for executing PHP code in parallel in a separate PHP process or thread. Classes implementing [`Task`](#task) are used to define the code to be run in parallel. ```php Resolves with the return value of Task::run(). */ public function enqueue(Task $task): Promise; /** * @return \Amp\Promise Exit code. */ public function shutdown(): Promise; /** * Immediately kills the context. */ public function kill(); } ``` ## `Task` The `Task` interface has a single `run()` method that gets invoked in the worker to dispatch the work that needs to be done. The `run()` method can be written using blocking code since the code is executed in a separate process or thread. The method may also be asynchronous, returning a `Promise` or `Generator` that is run as a coroutine. ```php