0

I am having a problem in replit. I know how to and have made threads before in other compilers like VS 2019. But for some reason in replit I am not able to create a new thread.

My current code:

#include <iostream>
#include <thread>
#include <pthread>

void waveThreader()
{
std::cout<<"Hello!";
}

int main()
{
std::cout<<"Start!";
std::thread thread1(waveThreader);
thread1.join();
return 0;
}

I tried using:

pthread_t thread1;
pthread_create(&wvy, NULL, waveThreader, NULL);

void * waveThreader(void *arguments)
{
  std::cout<<"Hello!";
  return NULL;
}

  • Why not use std::thread or std::async? They've been part of C++ since C++11. Work like a charm in combination with lambda functions. – Pepijn Kramer Oct 26 '22 at 18:24
  • @PepijnKramer ya I am currently using std::thread. but I always get an Undefined reference to `pthread_create' error... – user20342224 Oct 26 '22 at 18:34
  • yes that can still used under the hood ... I don't know replit, seems to support C++11. Maybe a configuration or a setting error I don't know – Pepijn Kramer Oct 26 '22 at 19:00

0 Answers0