目录

Delphi线程内部

unit System.Classes;

unit System;

unit System.Threading;  //Delphi的内部用户态线程库

如何池化线程并进行管理:

3.1、任务及其接口ITask--->TTask

3.2、未来:也是池化的任务接口

3.3、并行库,也是池化的:

当Application空闲Idle时你要在UI线程勤做的事情:


Delphi线程内部

unit System.Classes;


function ThreadProc(const Thread: TThread): Integer;
varFreeThread: Boolean;
{$IFDEF MACOS}pool: Pointer;
{$ENDIF MACOS}
begin
{$IFDEF AUTOREFCOUNT}Thread.__ObjAddRef; // this ensures the instance remains for as long as the thread is running
{$ENDIF}TThread.FCurrentThread := Thread;
{$IF Defined(POSIX)}if Thread.FSuspended thenpthread_mutex_lock(Thread.FCreateSuspendedMutex);
{$ENDIF POSIX}
{$IFDEF MACOS}// Register the auto release poolpool := objc_msgSend(objc_msgSend(objc_getClass('NSAutoreleasePool'),sel_getUid('alloc')), sel_getUid('init'));
{$ENDIF MACOS}tryThread.FStarted := True;if not Thread.Terminated thentryThread.Execute;exceptThread.FFatalException := AcquireExceptionObject;end;finallyResult := Thread.FReturnValue;FreeThread := Thread.FFreeOnTerminate;Thread.DoTerminate;Thread.FFinished := True;SignalSyncEvent;if FreeThread thenbeginThread.DisposeOf;
{$IFDEF AUTOREFCOUNT}Thread.__ObjRelease; // This will clear the thread reference that was added by setting FreeOnTerminate.
{$ENDIF}end;
{$IFDEF AUTOREFCOUNT}Thread.__ObjRelease; // This will clear the thread reference we added above. This may initiate disposal.
{$ENDIF}
{$IFDEF USE_LIBICU}// Destroy Collator Cacheif IsICUAvailable thenClearCollatorCache;
{$ENDIF}
{$IF Defined(MSWINDOWS)}EndThread(Result);
{$ELSEIF Defined(POSIX)}
{$IFDEF MACOS}// Last thing to do in thread is to drain the poolobjc_msgSend(pool, sel_getUid('drain'));
{$ENDIF MACOS}
{$IFDEF ANDROID}// Detach the NativeActivity virtual machine to ensure the proper relase of JNI context attached to the current threadPJavaVM(System.JavaMachine)^.DetachCurrentThread(PJavaVM(System.JavaMachine));
{$ENDIF ANDROID}// Directly call pthread_exit since EndThread will detach the thread causing// the pthread_join in TThread.WaitFor to fail.  Also, make sure the EndThreadProc// is called just like EndThread would do. EndThreadProc should not return// and call pthread_exit itself.if Assigned(EndThreadProc) thenEndThreadProc(Result);pthread_exit(Result);
{$ENDIF POSIX}end;
end;

unit System;

{ Thread support }
typeTThreadFunc = function(Parameter: Pointer): Integer;{$IFDEF POSIX}{$IFDEF LINUX}
typeTSize_T = Cardinal;TSchedParam = recordsched_priority: Integer;end;{$DEFINE _PTHREAD_ATTR_T_DEFINED}pthread_attr_t = record__detachstate,__schedpolicy: Integer;__schedparam: TSchedParam;__inheritsched,__scope: Integer;__guardsize: TSize_T;__stackaddr_set: Integer;__stackaddr: Pointer;__stacksize: TSize_T;end;{$EXTERNALSYM pthread_attr_t}
{$ENDIF LINUX}
{$IFDEF MACOS}
constPTHREAD_ATTR_SIZE = 36;SCHED_PARAM_SIZE = 4;
typeTSchedParam = recordsched_priority: Integer;opaque: array [0..SCHED_PARAM_SIZE-1] of Byte;end;{$DEFINE _PTHREAD_ATTR_T_DEFINED}pthread_attr_t = record__sig: LongInt;opaque: array [0..PTHREAD_ATTR_SIZE-1] of Byte;end;{$EXTERNALSYM pthread_attr_t}  // Defined in signal.h
{$ENDIF MACOS}{$IFDEF ANDROID}
typeTSize_T = Cardinal;{$DEFINE _PTHREAD_ATTR_T_DEFINED}pthread_attr_t = recordflags: UInt32;stack_base: Pointer;stack_size: TSize_T;guard_size: TSize_T;sched_policy: Int32;sched_priority: Int32;end;{$EXTERNALSYM pthread_attr_t}
{$ENDIF ANDROID}typeTThreadAttr = pthread_attr_t;PThreadAttr = ^TThreadAttr;TBeginThreadProc = function (Attribute: PThreadAttr;ThreadFunc: TThreadFunc; Parameter: Pointer;var ThreadId: TThreadID): Integer;TEndThreadProc = procedure(ExitCode: Integer);varBeginThreadProc: TBeginThreadProc = nil;EndThreadProc: TEndThreadProc = nil;
{$ENDIF POSIX}{$IFDEF MSWINDOWS}typeTSystemThreadFuncProc = function(ThreadFunc: TThreadFunc; Parameter: Pointer): Pointer;TSystemThreadEndProc = procedure(ExitCode: Integer);{$NODEFINE TSystemThreadFuncProc}{$NODEFINE TSystemThreadEndProc}(*$HPPEMIT 'namespace System' *)(*$HPPEMIT '{' *)(*$HPPEMIT '  typedef void * (__fastcall * TSystemThreadFuncProc)(void *, void * );' *)(*$HPPEMIT '  typedef void (__fastcall * TSystemThreadEndProc)(int);' *)(*$HPPEMIT '}' *)var// SystemThreadFuncProc and SystemThreadEndProc are set during the startup// code by the C++ RTL when running in a C++Builder VCL application.SystemThreadFuncProc: TSystemThreadFuncProc = nil;SystemThreadEndProc: TSystemThreadEndProc = nil;function BeginThread(SecurityAttributes: Pointer; StackSize: LongWord;ThreadFunc: TThreadFunc; Parameter: Pointer; CreationFlags: LongWord;var ThreadId: TThreadID): THandle;
{$ENDIF}
{$IFDEF POSIX}
function BeginThread(Attribute: PThreadAttr; ThreadFunc: TThreadFunc;Parameter: Pointer; var ThreadId: TThreadID): Integer;{$ENDIF}
procedure EndThread(ExitCode: Integer);{ Standard procedures and functions }const
{ File mode magic numbers }fmClosed = $D7B0;fmInput  = $D7B1;fmOutput = $D7B2;fmInOut  = $D7B3;{ Text file flags         }tfCRLF   = $1;    // Dos compatibility flag, for CR+LF line breaks and EOF checkstype
{ Typed-file and untyped-file record }TFileRec = packed record (* must match the size the compiler generates: 592 bytes (616 bytes for x64) *)Handle: NativeInt;Mode: Word;Flags: Word;case Byte of0: (RecSize: Cardinal);   //  files of record1: (BufSize: Cardinal;    //  text filesBufPos: Cardinal;BufEnd: Cardinal;BufPtr: _PAnsiChr;OpenFunc: Pointer;InOutFunc: Pointer;FlushFunc: Pointer;CloseFunc: Pointer;UserData: array[1..32] of Byte;Name: array[0..259] of WideChar;);end;{ Text file record structure used for Text files }PTextBuf = ^TTextBuf;TTextBuf = array[0..127] of _AnsiChr;TTextRec = packed record (* must match the size the compiler generates: 730 bytes (754 bytes for x64) *)Handle: NativeInt;       (* must overlay with TFileRec *)Mode: Word;Flags: Word;BufSize: Cardinal;BufPos: Cardinal;BufEnd: Cardinal;BufPtr: _PAnsiChr;OpenFunc: Pointer;InOutFunc: Pointer;FlushFunc: Pointer;CloseFunc: Pointer;UserData: array[1..32] of Byte;Name: array[0..259] of WideChar;Buffer: TTextBuf;CodePage: Word;MBCSLength: ShortInt;MBCSBufPos: Byte;case Integer of0: (MBCSBuffer: array[0..5] of _AnsiChr);1: (UTF16Buffer: array[0..2] of WideChar);end;TTextIOFunc = function (var F: TTextRec): Integer;TFileIOFunc = function (var F: TFileRec): Integer;procedure SetLineBreakStyle(var T: Text; Style: TTextLineBreakStyle);
function GetTextCodePage(const T: Text): Word;
procedure SetTextCodePage(var T: Text; CodePage: Word);
procedure __IOTest;
procedure SetInOutRes(NewValue: Integer);
procedure ChDir(const S: string); overload;
procedure ChDir(P: PChar); overload;
function Flush(var t: Text): Integer;
procedure _UGetDir(D: Byte; var S: UnicodeString);
procedure _LGetDir(D: Byte; var S: _AnsiStr);
procedure _WGetDir(D: Byte; var S: _WideStr);
procedure _SGetDir(D: Byte; var S: _ShortStr);
function IOResult: Integer;
procedure MkDir(const S: string); overload;
procedure MkDir(P: PChar); overload;
procedure Move(const Source; var Dest; Count: NativeInt);
procedure MoveChars(const Source; var Dest; Length: Integer); inline;
function ParamCount: Integer;
function ParamStr(Index: Integer): string;
procedure RmDir(const S: string); overload;
procedure RmDir(P: PChar); overload;
function UpCase(Ch: _AnsiChr): _AnsiChr; overload; inline;
function UpCase(Ch: WideChar): WideChar; overload; inline;

unit System.Threading;  //Delphi的内部用户态线程库

{ TThreadPool.TBaseWorkerThread }constructor TThreadPool.TBaseWorkerThread.Create(AThreadPool: TThreadPool);
begininherited Create(False);
//  Priority := tpHigher;FRunningEvent := TLightweightEvent.Create(False);FThreadPool := AThreadPool;ThreadPool.FThreads.Add(Self);
end;destructor TThreadPool.TBaseWorkerThread.Destroy;
beginif FRunningEvent <> nil thenFRunningEvent.WaitFor(INFINITE); // This waits for the Execute to actually be called.if ThreadPool <> nil thenThreadPool.FThreads.Remove(Self);FRunningEvent.Free;inherited Destroy;
end;procedure TThreadPool.TBaseWorkerThread.SafeTerminate;
beginif ThreadPool <> nil thenThreadPool.FThreads.Remove(Self);FreeOnTerminate := True;Terminate;
end;procedure TThreadPool.TBaseWorkerThread.Execute;
beginNameThreadForDebugging(Format('Worker Thread - %s #%d ThreadPool - %p', [ClassName, TInterlocked.Increment(WorkerThreadID), Pointer(ThreadPool)]));FRunningEvent.SetEvent;
end;

如何池化线程并进行管理:

3.1、任务及其接口ITask--->TTask

TTask = class(TAbstractTask, TThreadPool.IThreadPoolWorkItem, ITask, TAbstractTask.IInternalTask)
//............publicclass function CurrentTask: ITask; static; inline;constructor Create; overload; // do not call this constructor!!destructor Destroy; override;class function Create(Sender: TObject; Event: TNotifyEvent): ITask; overload; static; inline;class function Create(const Proc: TProc): ITask; overload; static; inline;class function Create(Sender: TObject; Event: TNotifyEvent; const APool: TThreadPool): ITask; overload; static; inline;class function Create(const Proc: TProc; APool: TThreadPool): ITask; overload; static; inline;class function Future<T>(Sender: TObject; Event: TFunctionEvent<T>): IFuture<T>; overload; static; inline;class function Future<T>(Sender: TObject; Event: TFunctionEvent<T>; APool: TThreadPool): IFuture<T>; overload; static; inline;class function Future<T>(const Func: TFunc<T>): IFuture<T>; overload; static; inline;class function Future<T>(const Func: TFunc<T>; APool: TThreadPool): IFuture<T>; overload; static; inline;class function Run(Sender: TObject; Event: TNotifyEvent): ITask; overload; static; inline;class function Run(Sender: TObject; Event: TNotifyEvent; APool: TThreadPool): ITask; overload; static; inline;class function Run(const Func: TProc): ITask; overload; static; inline;class function Run(const Func: TProc; APool: TThreadPool): ITask; overload; static; inline;class function WaitForAll(const Tasks: array of ITask): Boolean; overload; static;class function WaitForAll(const Tasks: array of ITask; Timeout: Cardinal): Boolean; overload; static;class function WaitForAll(const Tasks: array of ITask; const Timeout: TTimeSpan): Boolean; overload; static;class function WaitForAny(const Tasks: array of ITask): Integer; overload; static;class function WaitForAny(const Tasks: array of ITask; Timeout: Cardinal): Integer; overload; static;class function WaitForAny(const Tasks: array of ITask; const Timeout: TTimeSpan): Integer; overload; static;end;
ITask = interface(TThreadPool.IThreadPoolWorkItem)///  <summary>Waits for the task to complete execution within a specific milliseconds.</summary>function Wait(Timeout: Cardinal = INFINITE): Boolean; overload;///  <summary>Waits for the task to complete execution within a specific time interval.</summary>function Wait(const Timeout: TTimeSpan): Boolean; overload;///  <summary>Cancel the task.</summary>procedure Cancel;///  <summary>Checks the task's cancel staus. If the task is canceld, raise EOperationCancelled exception.</summary>procedure CheckCanceled;///  <summary>Starts the task, adding it to the currect queue.</summary>function Start: ITask;///  <summary>Return the task's status code.</summary>function GetStatus: TTaskStatus;///  <summary>Returns the unique integer Id</summary>function GetId: Integer;///  <summary>Task ID. Each Task has unique ID.</summary>property Id: Integer read GetId;///  <summary>Task's status code</summary>property Status: TTaskStatus read GetStatus;end;

3.2、未来:也是池化的任务接口

//...未来:也是池化的任务接口IFuture<T> = interface(ITask)[HPPGEN('HIDESBASE virtual System::DelphiInterface<IFuture__1<T> > __fastcall StartFuture() = 0')]function Start: IFuture<T>;function GetValue: T;property Value: T read GetValue;end;
///  <summary>///  Use this record to grab a "snapshot" of a threadpool's internal state. This is useful in peering into the///  inner workings of a threadpool for diagnostic purposes. Because the accessed threadpool continues to run,///  This snapshot may not be strictly accurate. Do not depend on this structure for anything other than simply///  hinting at the internal state./// 使用此记录可以获取线程池内部状态的“快照”。这在窥视线程池的内部工作以进行诊断时非常有用。由  /// 于被访问的线程池继续运行,因此此快照可能不完全准确。除了简单地暗示内部状态之外,不要依赖于这个结构///  </summary>TThreadPoolStats = recordprivate//...public///  <summary>Total number of worker threads within the thread pool</summary>property WorkerThreadCount: Integer read FWorkerThreadCount;///  <summary>Corresponds to the MinWorkerThreads property</summary>property MinLimitWorkerThreadCount: Integer read FMinLimitWorkerThreadCount;///  <summary>Corresponds to the MaxWorkerThreads property</summary>property MaxLimitWorkerThreadCount: Integer read FMaxLimitWorkerThreadCount;///  <summary>Number of threads waiting for work to do</summary>property IdleWorkerThreadCount: Integer read FIdleWorkerThreadCount;///  <summary>Number of global queued work requests</summary>property QueuedRequestCount: Integer read FQueuedRequestCount;///  <summary>Number of worker threads in the process of being retired</summary>property RetiredWorkerThreadCount: Integer read FRetiredWorkerThreadCount;///  <summary>Running average of CPU usage</summary>property AverageCPUUsage: Integer read FAverageCPUUsage;///  <summary>Current snapshot of CPU usage</summary>property CurrentCPUUsage: Integer read FCurrentCPUUsage;///  <summary>Shared value among worker threads to manage orderly thread suspension</summary>property ThreadSuspended: Integer read FThreadSuspended;///  <summary>Shared value among worker threads to manage orderly thread suspension</summary>property LastSuspendTick: Cardinal read FLastSuspendTick;///  <summary>Used by the monitor thread to keep from creating threads too quickly</summary>property LastThreadCreationTick: Cardinal read FLastThreadCreationTick;///  <summary>Used by the monitor thread to only create new threads when there is work to do</summary>property LastQueuedRequestCount: Integer read FLastQueuedRequestCount;///  <summary>///  When called from within a threadpool thread, returns the stats for the owning threadpool. Outside of a///  threadpool thread, this will return the stats for the default threadpool///  </summary>class property Current: TThreadPoolStats read GetCurrentThreadPoolStats;///  <summary>Returns the stats for the default threadpool</summary>class property Default: TThreadPoolStats read GetDefaultThreadPoolStats;end;
  [HPPGen(HPPGENAttribute.mkNoDefine)]TFuture<T> = class sealed(TTask, IFuture<T>)private//......protectedfunction Start: IFuture<T>;function GetValue: T;constructor Create(Sender: TObject; Event: TFunctionEvent<T>; const Func: TFunc<T>; APool: TThreadPool); overload;end;

3.3、并行库,也是池化的:

  TParallel = class sealedpublic typeTLoopState = classprivate type//.........private//.........strict protected//.........publicprocedure Break;procedure Stop;function ShouldExit: Boolean;property Faulted: Boolean read GetFaulted;property Stopped: Boolean read GetStopped;property LowestBreakIteration: Variant read GetLowestBreakIteration;end;TLoopResult = recordprivate//.........publicproperty Completed: Boolean read FCompleted;property LowestBreakIteration: Variant read FLowestBreakIteration;end;TIteratorEvent = procedure (Sender: TObject; AIndex: Integer) of object;TIteratorStateEvent = procedure (Sender: TObject; AIndex: Integer; const LoopState: TLoopState) of object;TIteratorEvent64 = procedure (Sender: TObject; AIndex: Int64) of object;TIteratorStateEvent64 = procedure (Sender: TObject; AIndex: Int64; const LoopState: TLoopState) of object;private type//.........publicclass function &For(Sender: TObject; ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorEvent): TLoopResult; overload; static; inline;class function &For(Sender: TObject; ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorEvent; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(Sender: TObject; ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorStateEvent): TLoopResult; overload; static; inline;class function &For(Sender: TObject; ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorStateEvent; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorEvent): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorEvent; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorStateEvent): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Integer; AIteratorEvent: TIteratorStateEvent; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer>): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer>; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer, TLoopState>): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer, TLoopState>; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer>): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer>; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer, TLoopState>): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Integer; const AIteratorEvent: TProc<Integer, TLoopState>; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(Sender: TObject; ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorEvent64): TLoopResult; overload; static; inline;class function &For(Sender: TObject; ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorEvent64; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(Sender: TObject; ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorStateEvent64): TLoopResult; overload; static; inline;class function &For(Sender: TObject; ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorStateEvent64; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorEvent64): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorEvent64; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorStateEvent64): TLoopResult; overload; static; inline;class function &For(Sender: TObject; AStride, ALowInclusive, AHighInclusive: Int64; AIteratorEvent: TIteratorStateEvent64; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64>): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64>; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64, TLoopState>): TLoopResult; overload; static; inline;class function &For(ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64, TLoopState>; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64>): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64>; APool: TThreadPool): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64, TLoopState>): TLoopResult; overload; static; inline;class function &For(AStride, ALowInclusive, AHighInclusive: Int64; const AIteratorEvent: TProc<Int64, TLoopState>; APool: TThreadPool): TLoopResult; overload; static; inline;class function Join(Sender: TObject; AEvents: array of TNotifyEvent): ITask; overload; static;class function Join(Sender: TObject; AEvents: array of TNotifyEvent; APool: TThreadPool): ITask; overload; static;class function Join(Sender: TObject; AEvent1, AEvent2: TNotifyEvent): ITask; overload; static; inline;class function Join(Sender: TObject; AEvent1, AEvent2: TNotifyEvent; APool: TThreadPool): ITask; overload; static;class function Join(const AProcs: array of TProc): ITask; overload; static;class function Join(const AProcs: array of TProc; APool: TThreadPool): ITask; overload; static;class function Join(const AProc1, AProc2: TProc): ITask; overload; static; inline;class function Join(const AProc1, AProc2: TProc; APool: TThreadPool): ITask; overload; static;end;

当Application空闲Idle时你要在UI线程勤做的事情:

function CheckSynchronize(Timeout: Integer = 0): Boolean;  //unit System.Classes;

Delphi线程内部相关推荐

  1. Delphi线程类的使用(1)

    Delphi线程类的使用 猛禽[Mental Studio](个人专栏)(BLOG) http://mental.mentsu.com 去年底我写过一篇文章<Delphi中的线程类.2.3.4. ...

  2. Delphi线程同步

    Delphi线程同步 总结一下Windows常用的几种线程同步技术. 1.Critical Sections(临界段),源代码中如果有不能由两个或两个以上线程同时执行的部分,可以用临界段来使这部分的代 ...

  3. C# 实现线程内部与界面控件交互

    线程内部无法直接调用web层控件的数据,及线程与界面数据无法直接调用,直接调用会报未知错误,一般解决方法有两种: 方法1:直接更改启动页面数据.是程序无法检测到线程,一般不建议这样解决: 方法二:使用 ...

  4. DELPHI 线程类

    转自http://www.cnblogs.com/chengxin1982/archive/2009/10/04/1577879.html Delphi中有一个线程类TThread是用来实现多线程编程 ...

  5. java 内部thread_Java代码质量改进之:使用ThreadLocal维护线程内部变量

    在上文中,<Java代码质量改进之:同步对象的选择>,我们提出了一个场景:火车站有3个售票窗口,同时在售一趟列车的100个座位.我们通过锁定一个靠谱的同步对象,完成了上面的功能. 现在,让 ...

  6. DELPHI线程创建与使用

    这个要看你这个函数是干什么的,如果不涉及界面VCL或数据操作等需要同步的事情,那么多个线程调用同一函数跟平常调用一个函数一样,没什么特别的地方,反之,则需要注意每个线程之间的同步问题 追问 我想调用这 ...

  7. delphi 线程安全list_Java的中的集合(容器)-List

    容器相关类都定义了泛型,我们在开发和工作中,在使用容器类时都要使用泛型.这样,在容器的存储数据.读取数据时都避免了大量的类型判断,非常便捷 我们发现Collection.List.Set.Map.It ...

  8. java 线程 内部_从Java中的main()内部在线程实例上运行wait()

    我正在使用java.lang.Object中的wait()的定时版本,并观察到它在两种不同的情况下的行为不同. 方案1:在线程中使用run()的默认定义 public static void main ...

  9. C# Form.Show()方法 的一些线程内部特性

    一般我们在多线程中,处理UI的一些界面更新: 得使用到Invoke: 但CheckForIllegalCrossThreadCalls=false;的方法一定不要用,不明白的话,大家可以上MSDN查这 ...

最新文章

  1. 数据库基础笔记(MySQL)3 —— 基础操作
  2. 01-.Net编程机制
  3. c语言对空指针memcpy,C语言memcpy 断错误
  4. mac电脑sublime text3安装pretty json插件
  5. SQLSERVER自动定时(手动)备份工具
  6. LeetCode_数组_中等题
  7. Java图书管理系统练习程序(四)
  8. C++笔记-C++11中default及delete的使用
  9. wpf 将Style应用到 ListView 中的 ListViewItem 元素
  10. 以下构成python循环结构的方法中正确的是_python教程:python循环结构
  11. JdbcTemplate 排序查询结果不一致问题
  12. win10 中 如何 按日期 对文件 进行检索(找到目录下,指定日期修改的文件)
  13. android recyclerview多布局_图文讲解RecyclerView的复用机制 ||Recyclerview进阶
  14. html特殊符号拉丁文,拉丁文字符号大全,罗马字母
  15. BM3D图像去噪算法原理及代码详解
  16. 运维技术相关基础面试
  17. PLog——一个简洁快速,小而美的C++异步日志库
  18. fasttext使用指南
  19. 小游戏项目及分工情况
  20. IOT设备配网绑定通讯流程

热门文章

  1. 云开发谁是卧底小程序源码
  2. 目标检测校正数据集图像形态
  3. jquery点击按钮切换样式
  4. 周末在厨房的一些思考
  5. 什么是Hibernate的并发机制
  6. POJ1300 Door Man
  7. VS修改背景保护色保护双眼有绝招
  8. Myeclipse破解方法及失败解决方案
  9. 【C++】买鸡问题练手题
  10. Nginx配置二级目录反向代理本机不同端口