1#include "EventLoop.h" 2#include "EventLoopThread.h" 3#include <stdio.h> 4 5void runInThread() 6{ 7 printf("runInThread(): pid = %d, tid = %d\n", 8 getpid(), muduo::CurrentThread::tid()); 9} 10 11int main() 12{ 13 printf("main(): pid = %d, tid = %d\n", 14 getpid(), muduo::CurrentThread::tid()); 15 16 muduo::EventLoopThread loopThread; 17 muduo::EventLoop* loop = loopThread.startLoop(); 18 loop->runInLoop(runInThread); 19 sleep(1); 20 loop->runAfter(2, runInThread); 21 sleep(3); 22 loop->quit(); 23 24 printf("exit main().\n"); 25} 26