开发者

OCCI createEnvironment Blocks My Thread

开发者 https://www.devze.com 2022-12-30 00:15 出处:网络
I\'m writing a multi-threaded application, where there is a main thread which distributes tasks to the worker threads. According to the task, a worker thread creates a connection, by using a global oc

I'm writing a multi-threaded application, where there is a main thread which distributes tasks to the worker threads. According to the task, a worker thread creates a connection, by using a global occi environment. When a worker thread completes its task, it closes the connection (I'm sure, ther开发者_如何学Goe is no exception thrown while termination).

My problem is that after a while(sometimes 5 mins, sometimes 5 hours) the threads cannot get connection from the environment, and they get blocked there.

What can be the problem?


I guess I didn't identify the problem correctly. I thought the threads get blocked, but actually they didn't, they simply exited there unexpectedly :). Problem solved.


Have you considered using a thread pool? Then you don't need to close the connection every time the work is done. Setting up/closing the database connection is also quite expensive, i think.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号