新delphi的線程TThread有了CreateAnonymousThread方法,如果再為它加一個可傳遞的參數不就更好了嗎?代碼如下:
TAnonymousThreadX<T> = <T>
Execute;
Create( AProc: TProc<T>
TThreadHelper= helper
CreateAnonymousThreadX<T>( ThreadProc: TProc<T>
TAnonymousThreadX<T>.Create( AProc: TProc<T>
=== TAnonymousThreadX<T>
TThreadHelper.CreateAnonymousThreadX<T>( ThreadProc: TProc<T>= TAnonymousThreadX<T>;
代碼挺簡單的,就是傳遞了一個方法及參數. 在線程裡調用就是了.
將以上代碼保存在一個單元中,引用了之後,就可以這樣用了:
//<Integer>(TestX,// T***=//<Integer>=).Start;
如果執行線程的方法有兩個,三個參數,對照著改就是了.
這樣用線程是不是更簡單一些了呢.