gabr42 / gabr42/OmniThreadLibrary

Thread pool stops working when a task is created while threads are being destroyed

Open
#40 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Pascal
Stars
513
Forks
147
PR merge metrics
No merged PRs in 30d

Description

There is this strange error i am encountering where omnithread stops scheduling tasks and just stops working...

Here is the code to reproduce the error i am having

Procedure PerformOperations(const task: IOmniTask);
Begin
Sleep(1000);
End;

procedure TForm1.Button1Click(Sender: TObject);
Var I: Integer;
begin
for I := 0 to 200 do
CreateTask(PerformOperations).
UnObserved.Schedule(ThreadPool);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
ThreadPool := CreateThreadPool('ThreadPool');
ThreadPool.MaxExecuting := 60;
ThreadPool.MaxQueued := 0;
end;

When i click on the button it creates 200 tasks fine, but while looking at the thread count from task manager, as soon as the threads starts decreasing if i click on button1 that moment then thread count suddenly drops to 0 and after that no matter how many times i click on button1 for scheduling tasks no thread is created and no function is performed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.