#!/usr/local/bin/pike Thread.Mutex mutex = Thread.Mutex(); int main(int argc, array(string) argv) { int sock = Public.Web.FCGI.open_socket("127.0.0.1:31337", 128); for (int i = 0; i < 8; i++) { Thread.Thread(request_loop, sock, i); } return (-1); } void request_loop(int sock, int id) { Thread.MutexKey key; Public.Web.FCGI.FCGI request = Public.Web.FCGI.FCGI(sock); for (int i = 1; ; i++) { key = mutex->lock(); request->accept(); destruct(key); request->write("Hello world, this is page view #%d generated by thread %d\n", i, id); sleep(0.5); // any blocking operations can happen here without impacting other clients request->finish(); } }