DELPHI中运行会有类似这样的错误,
Project1.exe faulted with message: 'access violation at 0x00406761: write of address 0x01de0e08'. Process Stopped. Use Step or Run to continue.
如果直接运行程序,有时还有个提示出错了,有时什么提示也没有就退出了for i:=1 to 20 do 
CreateThread(nil, 0, @CheckAcc, pointer(id), 0, dwThreadID);
procedure CheckAcc(vid:Integer);stdcall;
var
   str:String;
   idhttp1:TIdHTTP;
begin
        try
        idhttp1:=TIdHttp.Create;
        str:=idhttp1.Get('http://www.163.com/');
     except
         idhttp1.Free;
         exit;
     end;
     idhttp1.Free;
end;

解决方案 »

  1.   

    你跟踪一下吧,看看错误是怎么出现的,是get出错还是啥的
      

  2.   

    就是GET出错啊,不加这个就不会出错,
    单独的也不会出错,多个线程同时执行就有可能出错了, 不知道该怎么办了
      

  3.   

    except与
    end
    中间什么都不加试试看
      

  4.   

    用TThread似乎没啥问题。type
      THttpThread = class(TThread)
      private
        FVID: Integer;
      protected
        procedure Execute; override;
      public
        constructor Create(vid: Integer);
      end;{ THttpThread }constructor THttpThread.Create(vid: Integer);
    begin
      inherited Create(true);
      FreeOnTerminate := True;
      FVID := vid;
      Resume;
    end;procedure THttpThread.Execute;
    var
      str: string;
      idhttp1: TIdHTTP;
    begin
      idhttp1 := TIdHttp.Create;
      try
        try
          str := idhttp1.Get('http://www.163.com/');
        except
        end;
      finally
        idhttp1.Free;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
      i: Integer;
    begin
      for i := 1 to 20 do
      begin
        THttpThread.Create(i);
      end;
    end;
      

  5.   

    另外补充个关于Delphi中CreateThread的资料。
    http://www.cnasm.com/view.asp?classid=61&newsid=297
      

  6.   

    如果你不想用TThread那就用BeginThread代替CreateThread吧。