Just for future reference if anyone wants to use it:
The following approach works perfectly fine for multiple workers too.

class MyDataset(Dataset):
    def __init__(self, num_workers, num):
        self.num = num
        self.num_workers = num_workers
        self.nb_samples = 20
        self.data = np.ones(self.nb_samples)

    def __getitem__(self, index):
        self.data[index] = self.num
        return self.data[index]

    def __len__(self):
        return self.nb_samples

    def set_sample(self, num):
        self.num = num


num_workers = 12
dataset = MyDataset(num_workers, 8)
loader = DataLoader(dataset, num_workers=num_workers, shuffle=False)
idx = 0
while idx < loader.__len__():
    if idx == 3:
        dataset.set_sample(12)
    data = next(iter(loader))
    print(f'{idx}  {data}, num_workers: {num_workers}')
    idx += 1


0  tensor([8.]), num_workers: 12
1  tensor([8.]), num_workers: 12
2  tensor([8.]), num_workers: 12
3  tensor([12.]), num_workers: 12
4  tensor([12.]), num_workers: 12
5  tensor([12.]), num_workers: 12
6  tensor([12.]), num_workers: 12
7  tensor([12.]), num_workers: 12
8  tensor([12.]), num_workers: 12
9  tensor([12.]), num_workers: 12
10  tensor([12.]), num_workers: 12
11  tensor([12.]), num_workers: 12
12  tensor([12.]), num_workers: 12
13  tensor([12.]), num_workers: 12
14  tensor([12.]), num_workers: 12
15  tensor([12.]), num_workers: 12
16  tensor([12.]), num_workers: 12
17  tensor([12.]), num_workers: 12
18  tensor([12.]), num_workers: 12
19  tensor([12.]), num_workers: 12