DELPHI XE7 New Parallel libraries

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.