MySQL自定义了一个函数pthread_create(与Linux下的pthread_create函数同名),在windows系统下,pthread_create调用_beginthread实现线程创建。
调用序列如下:
os_thread_create->pthread_create->_beginthread
通过自定义的pthread_create函数创建的线程有:
1. io_handler_thread
2. srv_lock_timeout_and_monitor_thread
3. srv_error_monitor_thread
4. srv_master_thread
5. trx_rollback_or_clean_all_without_sess
另外,MySQL定义了一个Threads类,通过此类的方法createThread调用windows下的CreateThread函数或linux下的pthread_create函数来创建线程。与此相关被创建的线程包括:
Database:数据库实例
PageWriter:刷出数据到外存
Scheduler:调度功能
SerialLog:日志
Server:socket监听进程