GetData 需要一个参数传进去作为查询数据库的参数,并做一系列处理,而Synchronize不允许带参数,所以定义了一个全局变量sLoginName,在线程内调用GetData前赋值,之后再置为空,这样安全不安全?
  sLoginName:=stLogin.LoginName;
  AThread.Synchronize(GetData);
  sLoginName:='';对线程不太了解,请各位谈谈各自是如何处理带参数的Synchronize 。

解决方案 »

  1.   

    Synchronize是在线程内用的,一般如果需要传递参数可以在线程内设置私有成员
      

  2.   

    http://blog.csdn.net/linzhengqun
    ////////
    建意看看里面关于线程的文章,讲得很详细
      

  3.   

    在线程类里定义一个变量为要转递的参数,比如:a : integer;AThread.a := 10;
    Athread.Resume;
    //
    这样就行
      

  4.   

    AThread:TIdPeerThread
    为系统的定义,不好修改
      

  5.   

    If sLoginName is only changed in your thread and there is  only one instance of this thread in application, it's OK.