assert or execption case program hang in multi thread

Qian Xu quian.xu at stud.tu-ilmenau.de
Tue Feb 24 14:05:36 PST 2009


liyu wrote:
> code as below, assert can't terminate the program when main thread is 
> running, is it a bug or i miss something?
> 
> import tango.core.Thread;
> void test()
> {
>     while(1) {
>         assert(false);
>         //throw new Exception("test");
>     }
> }
> 
> void main() {
>     auto thread = new Thread(&test);
>     thread.start();
> 
>        //if i remove the 3 lines below, then every thing work as expected
>     while(1) {
>         Thread.sleep(100);    }
> }


you should write thread.join() instead of Thread.sleep(100);

the syntax might be incorrect. search "join" in the thread class in tango.

have a nice day ^^)


-- 
Xu, Qian (stanleyxu)
 http://stanleyxu2005.blogspot.com



More information about the Digitalmars-d mailing list