-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Worker thread initation #34
Comments
Like 'lazy initialization' ? the worker won't be created until a task execution request come? |
就是线程要先加载完数据,进入ready状态再开始接受任务请求 现在是线程刚创建就开始接收请求了,本身其实还在执行加载 |
@mt4c 这里的实现其实是内部有一个任务队列,所有的任务执行请求都会先将任务添加进队列中,然后等待一个线程来取走它。如果是已经有空闲的线程,那么任务会被立即取走执行,反之则在队列中等待。并且所有的线程都只会在 ready 之后才会从队列取任务执行。而且这里并没有特别的优先级策略,哪个线程先 ready 就哪个线程去任务队列头部取任务执行,所以我理解你的问题或许是其他的原因导致的? |
我这里线程代码的结构是这样的
之前由于某些原因,doJob会抛出异常,导致线程挂掉,此时系统会开启一个新线程。 |
@mt4c 听上去是个新功能 👀 比如让 worker 里的程序自己决定什么时候 ready |
是的 |
Can you guys please suggest a book to learn Chinese (JK) :)? Would appreciate it if we keep the discussion in English. This seems to be a nice library and I would certainly like to contribute if I know what's being talked about. |
@thatisuday Hi. We're just talking about a new feature that allow threads itself to decide when to be ready to be picked up by the main thread to execute tasks rather than decide by the main thread. |
Now the threads are in the pool as soon as they are created.
In my project the worker threads spend long time on initation and I don't want them to be in the pool before they are ready to serve.
The text was updated successfully, but these errors were encountered: