Clock Sync in different thread

Hey! I am creating an application that syncs clocks, which works perfectly, but the moment i try to put my function that uses wait_for_clock_sync in a different thread it never syncs up

this it the code i use inside thread: (omitted by a bit, but it doesnt get past sync anyway)

    // Connect to the network clock
    GstClock* net_clock = gst_net_client_clock_new("net_clock", clockIP, port, 0);
    if (!GST_IS_CLOCK(net_clock)) {
        std::cerr << "Failed to connect to network clock" << std::endl;

    // Synchronize to the network clock
    gst_clock_wait_for_sync(net_clock, 5*GST_SECOND);

    // Get currentTime
    GstClockTime currentTime = gst_clock_get_time(net_clock);

    // Calculate the target time
    GstClockTime targetTime = targetTimeMs * GST_MSECOND;

    std::cout << "Current Clock Time: " << currentTime << std::endl;
    std::cout << "Clock Target Time:  " << targetTime << std::endl;

    // Create a single-use GstClockID for the target time
    GstClockID clockId = gst_clock_new_single_shot_id(net_clock, targetTime);

    // Wait for the clock to reach the target time
    GstClockReturn waitResult = gst_clock_id_wait(clockId, nullptr);

    QFileInfo file(filePath.c_str());
    QString extension = file.suffix().toLower();
    if (waitResult == GST_CLOCK_OK) {
       std::cout << "CLOCK\n";
    } else {
        std::cerr << "Waiting on clock failed." << std::endl;

    // Cleanup

Fixed it by putting sync out of thread and than putting wait for clock in thread.