Имеет смысл сразу при создании передавать в поток указатель на переменную, в которую поток должен будет сохранить результат:
#include <pthread.h>
#include <iostream>
#include <new>
#include <memory>
#include <cstdlib>
void * func(void * param) noexcept
{
auto const pp_int{static_cast<int * *>(param)};
(*pp_int) = new (::std::nothrow) int{10};
return nullptr;
}
int main()
{
int * p_int{};
::pthread_t thread_handle{};
auto const create_result
{
::pthread_create
(
::std::addressof(thread_handle)
, nullptr
, func
, static_cast<void *>(::std::addressof(p_int))
)
};
if(0 == create_result)
{
auto const join_result{::pthread_join(thread_handle, nullptr)};
if(0 != join_result)
{
::std::abort();
}
if(nullptr != p_int)
{
::std::cout << (*p_int) << ::std::endl;
delete p_int;
p_int = nullptr;
}
}
return 0;
}