OmniThreadLibrary icon indicating copy to clipboard operation
OmniThreadLibrary copied to clipboard

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

Open JunaidNoor1 opened this issue 10 years ago • 3 comments

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.

JunaidNoor1 avatar Jul 16 '15 05:07 JunaidNoor1

Hmmmm, this looks bad. It definitely shouldn't behave in this way. I'll look into it.

gabr42 avatar Jul 16 '15 08:07 gabr42

thanks. i am looking forward to the fix

JunaidNoor1 avatar Jul 16 '15 08:07 JunaidNoor1

@JunaidNoor1 In which version of the Omni thread library you are facing this issue? What is the Delphi version you are using?

rajeshkomatlapalli avatar Feb 24 '21 14:02 rajeshkomatlapalli