zoukankan      html  css  js  c++  java
  • 线程函数问题

    If you are rusty on your C++, let me remind you of the problem. 
    Every C++ member function has a hidden first passed parameter known as the this parameter.
    Via the this parameter, the function knows which instance of the class to operate upon.
    Because you never see these this parameters, it is easy to forget they exist.
    Now, let's again consider the _beginthread() function which allows us to specify an arbitrary entry-point-function for our new thread.
    This entry-point-function must accept a single void* passed param.
    Aye, there's the rub. The function signature required by _beginthread() does not allow the hidden this parameter,
    and hence a C++ member function cannot be directly activated by _beginthread().
    意思就是说,C++类中的成员函数其实默认在参数中包含有一个this指针,
    这样成员函数才知道应该对哪个实例作用。而线程函数必须接受一个void指针作为参数,所以导致了矛盾。
    为了解决矛盾,我们可以使用static函数,它独立于实例,参数中将不会有this指针,所以可以用于打开线程
  • 相关阅读:
    重定向丶管道丶参数传递
    zabbix监控redis
    zabbix监控mysql
    playbook
    zabbix通过jvm监控tomcat
    zabbix监控tcp状态
    部署centos6
    自动选择profile
    java jvm学习笔记十二(访问控制器的栈校验机制)
    java jvm学习笔记十一(访问控制器)
  • 原文地址:https://www.cnblogs.com/Eiffel/p/5954282.html
Copyright © 2011-2022 走看看