Comments (4)
是的,确实应该写到前面,逻辑上更准确,多谢。
马上修改
from zl_threadpool.
@fengluyan 已修正,多谢。see b9e604e
from zl_threadpool.
其实我是知乎上看到来学习的,我感觉写在后面出现问题的概率非常非常低但还是可能会出现.写在前面就肯定没问题了.感谢奉献代码供我等学习
from zl_threadpool.
是,你考虑的很周到,当时就随手一写一测,没考虑周全。
是有可能出问题的,比如创建线程很快,线程函数在isRunning_ =true之前就运行了。改后语义更明确了。
不过,其实也不会有问题的,哈哈,因为这个是bool变量,在置true之前他的值是随机的,基本不会是0,所以还是会按正常情况运行的。
createThreads();
isRunning_ = true;
你在上面两句话的中间加一个sleep(10)等待10s,使线程函数先执行,会发现线程函数并不会退出的。
当然这是未定义行为,歪打正着。
还是修正了,多谢提醒!
from zl_threadpool.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zl_threadpool.