I am a beginner. I did not work with pointers yet.
Which is no excuse for not applying the basics
I did not understand what I would need to modify.
Could you please detail more what I would need to modify?
Let's start with something fundamental and change:
IF vloop > Length(n) - 1 THEN
searches[j] := f.Create(n[i], s) //do not use threads for this case
ELSE
searches[j] := f.Create(n[i + j], s);
into
IF vloop > Length(n) - 1 THEN
searches[j] := find.Create(n[i], s) //do not use threads for this case
ELSE
searches[j] := find.Create(n[i + j], s);
At least that lets the threads run
Drats, now the main program will not stop running.
So, taking a closer look at:
PROCEDURE FIND.Execute;
VAR
i : INTEGER;
BEGIN
FOR i := 0 TO Length(_sentence) - 1 DO
IF AnsiContainsText(_sentence[i], _name) THEN
BEGIN
_isfound := True;
exit;
END;
_isready := True;
END;
Which makes the following check fail:
{Wait for threads to finish}
WHILE no_threads_ready <> no_threads DO
BEGIN
no_threads_ready := 0;
j := 0;
FOR j := 0 TO no_threads - 1 DO
IF searches[j].IsReady THEN
no_threads_ready := no_threads_ready + 1;
END;
Can you spot the why ?