http://d.puremagic.com/issues/show_bug.cgi?id=3054

           Summary: multithreading GC problem. And Stdio not
                    multithreading safe
           Product: D
           Version: 2.028
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Phobos
        AssignedTo: bugzi...@digitalmars.com
        ReportedBy: dav...@126.com


import core.thread;
import std.stdio;
class threadid
{
    static int threadid;
    static int threadnum;
    int getId(){threadid++; return threadid; }
}
threadid TID;
void main()
{
    TID = new threadid;
    while(true)
    {
        try
        {
            synchronized(TID) if (TID.threadnum<500)
            {
                auto stress = (new Thread(
                    (){
                        int tid;
                        synchronized(TID){ tid = TID.getId(); }
                        scope(exit) synchronized(TID){TID.threadnum--;}
                        synchronized(TID){TID.threadnum++;}
                        //writefln("new thread:", tid, TID.threadnum);    
                        void[] buffer;
                        try
                        {
                            buffer.length= 65536;
                        }
                        catch(Exception e)
                        {
                            writefln("thread:", tid);    
                            writefln(e.msg);
                        }
                    }
                ));        
                stress.start();
            }    
            //writefln("outside:", TID.threadnum);    
        }
        catch(Exception e)
        {
            //writefln("error: ", e.msg);
        }
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to