Exception can't work in multithreading
King Dark
gdxxhg at gmail.com
Mon Mar 17 07:29:06 PDT 2008
Hi, I am recently writing a web server and it needs multi-threading. But I met a problem that the exception can not work after I create a thread.
This is the code without multi-threading, it works well.
try{
printf("exception1");
throw new Exception("hello");
}catch( Exception e ){
printf("exception3");
}
It printed "exception1" and "exception3" in console.
This is the code with multi-threading:
server.start(); //creates a listening thread for socket.
try{
printf("exception1");
throw new Exception("hello");
}catch( Exception e ){
printf("exception3");
}
It printed "Error: Hello" in console.
I don't know why. I think my code of multi-threading is correct( as I am using std.thread ). Have any one ever met the same problem?
By the way, the "try catch" seems cannot catch the exception such as "divided by zero". It crushed after running such code.
More information about the D.gnu
mailing list