[fpc-pascal] How can I write a multithread program as simple as possible?

Michael Schnell mschnell at lumino.de
Wed May 27 09:49:10 CEST 2015


On 05/26/2015 06:12 PM, Géza Kovacs Géza wrote:
> I read the Wiki about this article, it's looks like very complicated for me. :-(
AFAIK, there are examples on how to create TThreads in the fpc Wiki.

OTOH performance optimization via threads on multi-Core systems is not 
the original target of thread programming, but of course it's a decent 
way t make use of it.

Delphi does provide easy to use library calls for this (using the 
"Anonymous" syntax). AFAIK, fpc does have the "Anonymous" syntax since 
some time, and hopefully the library will be enhanced for such "parallel 
loops" some day soon.

Before this, you need to create the threads using TThread.

In fact doing a thread pool would be more appropriate.

I already did a workable draft of a thread pool unit that is usable for 
such tasks, but provided that a Delphi compatible "Anonymous parallel 
loop" library might be the better way to go I stopped working on that.

-Michael




More information about the fpc-pascal mailing list