C++ Boost线程在stdout上没有显示输出

C++ Boost线程在stdout上没有显示输出,c++,multithreading,boost,C++,Multithreading,Boost,我正在尝试使用boost线程库。下面是一个示例代码 由于某种原因,我没有看到任何输出 int main() { myclass Class1; while(1) { } } /************************************/ typedef boost::shared_ptr<boost::thread> thread_ptr; // class definition myclass::myclass() { // thread_

我正在尝试使用boost线程库。下面是一个示例代码

由于某种原因,我没有看到任何输出

int main()
{
  myclass Class1;
  while(1) {
  }
}

/************************************/

typedef boost::shared_ptr<boost::thread> thread_ptr;

// class definition

myclass::myclass()
{
    // thread_ptr is of type thread_ptr
    threat_ptr1 = thread_ptr(new boost::thread(&myclass::function_name, this)); 
}
void myclass:function_name()
{
    std::cout << "enter here";
    while( true ) {
        boost::this_thread::sleep(boost::posix_time::seconds(2));
        // do some stuff
    }
}
intmain()
{
我的班级1;
而(1){
}
}
/************************************/
typedef boost::共享线程;
//类定义
myclass::myclass()
{
//螺纹ptr为螺纹ptr类型
threat_ptr1=thread_ptr(新的boost::thread(&myclass::function_name,this));
}
void myclass:function_name()
{
std::cout代替

std::cout << "enter here";

std::我不希望你擦了因为你忘了冲水!@CaptainObvlious-当然是因为你冲水了?走开!盲人怎么知道什么时候停止擦?@EdHeal Bunghole Braille?@CaptainObvlious还是找一条忠实的狗?为什么冲水不是原因呢?@enter here”只写入缓冲区(std::cout是缓冲区!)。此缓冲区从未写入标准输出-->否output@Bob例如,见
std::cout << "enter here" << std::endl;