Implementation of execution of database work in a separate thread.