Tasks / Threads created by TParallel are more or less persistent which might be good for reusability. However, I would like to see a class method for cleaning up.
TParallel.For(0, 20, (procedure(A : integer) begin writeln(A) end));
The above code leaves threads behind, which can be observed with task manager.
Would creating your own TThreadPool instance and disposing of it when no longer needed satisfy you…?
var Pool: TThreadPool; begin Pool := TThreadPool.Create; try TParallel.For(0, 20, (procedure(A : integer) begin writeln(A) end), Pool); Write('Disposing of the thread pool - press ENTER to continue...'); finally Pool.DisposeOf; end; end;
The thread pool remains existent for efficient reuse. A TThreadpool is recommended when explicit management of the threads is desirable.
Delphi / Object Pascal
- Delphi is 30 Years Old!
- Reviews of FixInsight - Delphi Static Code Analyser
- Lighting-fast Delphi 2007 Compiling Speed
- The Inline Keyword in Delphi
- Does Parallel.For in Delphi Actually Improve the Performance?
- Delphi TParallel Cleanup Needed
- Delphi Compiles Code to Linux 64-bit Server
- Integer Performance Comparisons of Delphi Win32, Win64 and Linux64 for Single/Multithreading Counting Prime Number
- How to Check If Running in 64-bit Windows Environment using Delphi?
- How to Check Debugger Present in Delphi?
- Delphi Static Code Analyser - FixInsight
- Optimal SizeOf Code Generated in Delphi 2007
–EOF (The Ultimate Computing & Technology Blog) —
GD Star Rating
loading...
187 wordsloading...
Last Post: QuickhostUK - WordPress - Brute Force Amplification Attacks Against XMLRPC
Next Post: Simple Parallel.For Implementation at Delphi 2007 without Generics and Anonymous Methods