Skip to content

Unexpected stuck thread #110

@DeepLearnerYe

Description

@DeepLearnerYe

The thread is running well when the function is simple. However, I encountered a stuck thread using my own function. Here is a simple example.

// running perfectly good
thread_pool->enqueue([]()
{
while(1)
{
std::this_thread::sleep_for(std::chrono::seconds(1));
std::cout << "thread running...." << std::endl;
} 
});
// I can see "myFunction() running". But my logic never starts to execute.
void myFunction()
{
std::cout << "myFunction() running" << std::endl;
	while(1)
	{
		// some logic...
	}
}

thread_pool->enqueue([]()
{
	myFunction();
});

I created a thread myself to run my function, and it succeeded. So, that should not be the problem of my funtion, maybe there's a bug or something in the threadpool?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions