From 0adb6f572b0456ab7dcb975ebc0bc9b43005fdae Mon Sep 17 00:00:00 2001
From: Adriano Meligrana <68152031+Tortar@users.noreply.github.com>
Date: Tue, 3 Dec 2024 14:47:07 +0100
Subject: [PATCH] Update search_and_matching.jl

---
 src/markets/search_and_matching.jl | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/markets/search_and_matching.jl b/src/markets/search_and_matching.jl
index f5c14c4..d20b75a 100644
--- a/src/markets/search_and_matching.jl
+++ b/src/markets/search_and_matching.jl
@@ -108,8 +108,10 @@ function search_and_matching!(model, multi_threading = false)
 
 
     if multi_threading
-        Threads.@threads :static for g in 1:G
-            loopBody(Threads.threadid(), g)
+        Threads.@sync for (i, gs) in enumerate(chunks(1:G; n=Threads.nthreads(), split=RoundRobin()))
+            for g in gs
+                Threads.@spawn loopBody(i, g)
+            end
         end
     else
         for g in 1:G