Question about threads

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Tue Apr 17 08:40:09 PDT 2007


Ary Manzana wrote:

> class MyThread : Thread {
> 
>     char fChar;
>     this(char c) {
>         fChar = c;
>     }
>     
>     int run() {
>         while(true)
>             writef("%s", fChar);
>         return 0;
>     }
>     
> }
> 
> void main(char[][] args) {
>     MyThread t1 = new MyThread('.');
>     MyThread t2 = new MyThread('!');
>     
>     t1.start();
>     t2.start();
> }
> -----------------------------------------------
> 
> Running the above program in Windows makes it crash (I get the "program
> X encountered a problem and must be closed" message). Why is this
> happenning?

You probably have to end the execution of t1 and t2 before returning
from main().


More information about the Digitalmars-d-learn mailing list