The new feature List of DELPHI XE7 adds the parallel library system.threading, System.syncobjs.
Why add a new parallel library?
or for cross-platform. In the past to parallel programming only from the TThread class inheritance for multithreading, you know that the TThread class is packaged from the Windows Threading API, it encapsulates the windows of multi-threaded things, is not out of Windows, of course, is not cross-platform. Delphi is now walking is the original cross-platform road, all of Delphi's basic class library from only support Windows to support multi-platform, this is a large and slow project, in recent years, we have seen the Iboron in this effort, Delphi has made many amazing improvements in cross-platform terms, and Delphi is not just a development tool bundled with Windows.
Along with some new syntax provided by the new Delphi version: Generics, anonymous functions ...
Here's the official demo code:
Thousand notes: Uses System.Threading, SYSTEM.SYNCOBJS;
Procedure Tform1.button1click (Sender:tobject);
Var
Tasks:array of ITask;
Value:integer;
Begin
Value: = 0;
tasks: = [
Ttask.create (Procedure
Begin
Sleep (1000);
Tinterlocked.add (value, 1000);
End). Start,
Ttask.create (Procedure
Begin
Sleep (1000);
Tinterlocked.add (value, 3000);
End). Start,
Ttask.create (Procedure
Begin
Sleep (1000);
Tinterlocked.add (value, 5000);
End). Start
];
Ttask.waitforall (tasks);
ShowMessage (' All done: ' + value. ToString);
End
Compared with the original Ttread, who is superior to who is inferior?
It says that the new parallel libraries are just for cross-platform, and if you're only programming on Windows, you can still use the Ttread class to perform efficiently.
Http://www.cnblogs.com/hnxxcxg/p/4109990.html
DELPHI XE7 New Parallel libraries