{ %skiptarget=$nothread } {$mode objfpc} {$ifdef CPUWASM32} { This test runs out of memory, when using the default WebAssembly shared memory limit of 256 MiB, so we increase it to 512 MiB } {$M 1048576,536870912,536870912} {$endif} uses {$ifdef unix} cthreads, {$endif} sysutils ; const {$if defined(cpuarm) or defined(cpuavr) or defined(cpui8086) or defined(cpum68k) or defined(cpumips) or defined(cpuz80)} {$define slowcpu} {$endif} {$ifdef slowcpu} threadcount = 40; stringlen = 2000; {$else slowcpu} threadcount = 100; stringlen = 10000; {$endif slowcpu} var finished : longint; threadvar thri : longint; function f(p : pointer) : ptrint; var s : ansistring; begin writeln('thread ',longint(p),' started'); thri:=0; while (thri tthreadid(0) then inc(started); while volatile(finished)