我现在在写考勤系统。
在收取打卡数据时因数据太多,所以想用多线程。
因考勤机有20台,所以想做5个线程,同时收取5台的数据,看了关于多线程的书,不太明白。
请大家提供一个思路或方案。
谢了。

解决方案 »

  1.   

    开6个线程
    1个为管理线程,他是执行完不会推出的,其他的谁便你。constructor CtrlSound.Create;
    begin
      FreeOnTerminate := True;  //加上这一句,运行完会释放
      inherited Create(False);
    end;
    在管理线程,处理数据,并把他交给下面的线程处理
      

  2.   

    zsy_good(只要坚定不移的走下去,那一定会成功) 
    =============================
    constructor CtrlSound.Create;
    begin
      FreeOnTerminate := True;  //加上这一句,运行完会释放
      inherited Create(False);
    end;
    ==============================
    你这个是用windows 的API调用.
    我的调用同一个过程,有没有问题啊?
      

  3.   

    我的是这样写的:
    type
      TRecKQJThread = class(TThread)
      private
        KqjJH:Integer;
        RecT:array[1..5] of TRecKQJThread ; public
        { Private declarations }
      protected
        procedure Execute; override;
      public
        constructor Create(KJH:Integer);
        { Public declarations }
      end;constructor TRecKQJThread.Create(KJH:Integer);
    begin
       KqjJH:=KJH;
       inherited Create(True);
    end;procedure TRecKQJThread.Execute;
    begin
    ......
    ......//处理过程
    end;问题1:我怎么知道线程执行完了
    问题2:其它考勤机怎样排队执行
    谢了
      

  4.   

    我的是这样写的:
    type
      TRecKQJThread = class(TThread)
      private
        KqjJH:Integer;
        RecT:array[1..5] of TRecKQJThread ; public
        { Private declarations }
      protected
        procedure Execute; override;
      public
        constructor Create(KJH:Integer);
        { Public declarations }
      end;constructor TRecKQJThread.Create(KJH:Integer);
    begin
       KqjJH:=KJH;
       inherited Create(True);
    end;procedure TRecKQJThread.Execute;
    begin
    ......
    ......//处理过程
    end;问题1:我怎么知道线程执行完了
    问题2:其它考勤机怎样排队执行
    谢了
      

  5.   

    线程有一个回调函数
    constructor CtrlSound.Create;
    begin
      FreeOnTerminate := True;
      OnTerminate := ThreadRecordStop;     //这里回调
      inherited Create(False);
    end;
    procedure TForm1.ThreadRecordStop(Sender: TObject);
    begin
      showmessage('线程执行完了');
    end;