@LeP
That also compiles in fpc trunk, although TTask from system.threading (in vcl-compat package) needs more work.
Then again, that code works in Delphi - 12.1 - unreliably/by accident.
In fpc it works even more unreliable.
Both compilers compile it, but there is an issue with the code since it deadlocks on and off in both.
That is also easily explained since the threads are not stored in outer scope, so you can't see if they are finished and then call waitfor.
Not a good solution.... I used this complete code to test and am now fixing it (for both compilers):
{$APPTYPE CONSOLE}
{$ifdef fpc}{$mode delphi}{$endif}
uses sysutils, classes, syncobjs, system.threading;
procedure TimeCall(MilliSeconds: integer);
begin
TTask.Run(procedure
begin
sleep (Milliseconds);
//I use TThread.Synchronize only 'cause writeln is a shared resource use by multiple concurrent thread
TThread.Synchronize(TThread.Current,
procedure
begin
writeln ('Hello, I come after + '+Milliseconds.ToString);
end);
end);
end;
begin
TimeCall(500); //This will show for THIRD
TimeCall(200); //This will show for SECOND
TimeCall(1000); //This will show for FIFTH
TimeCall(750); //This will show for FOURTH
//I do other things, like show another message
writeln('I am the first'); //This will show for FIRST
end.
BTW, I think you don't need to worry about writeln in fpc, since it is, unlike Delphi, fully serialized already?
When I fixed the code, I will post the proper code.(hopefully, but this is no good either

)