How can I create an Object inside a thread function?....I'm trying to create a new thread that handles a small webserver. The thread fucntion doesn't seem to create the webserver object though. The webserver class itself works fine, but once I try to put it in a seperate thread nothing seems to work.

Heres how I am starting the new thread
Code:
UINT StartWebServer(LPVOID param)
{
	WebServer *webServer;
	webServer = new WebServer(HTTPPORT);
	webServer->Run();
	return 1;
}
Calling beginthread in another class as follows

AfxBeginThread(&StartWebServer, NULL, THREAD_PRIORITY_NORMAL, 0, 0, NULL);


why does this not work? how can I fix it

Thanks