Skip to content

Commit 70f997b

Browse files
authored
Merge pull request #148 from actboy168/patch-2
fixes bug when worker>64
2 parents c9b75e9 + 5b59985 commit 70f997b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/thread.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,14 @@ thread_start(struct thread * threads, int n, int usemainthread) {
8484
static inline void
8585
thread_join(void *handle, int n) {
8686
HANDLE *thread_handle = (HANDLE *)handle;
87-
WaitForMultipleObjects(n, thread_handle, TRUE, INFINITE);
8887
int i;
88+
for (i = 0; i < n; i += MAXIMUM_WAIT_OBJECTS) {
89+
int size = n - i;
90+
if (size > MAXIMUM_WAIT_OBJECTS) {
91+
size = MAXIMUM_WAIT_OBJECTS;
92+
}
93+
WaitForMultipleObjects(size, &thread_handle[i], TRUE, INFINITE);
94+
}
8995
for (i=0;i<n;i++) {
9096
CloseHandle(thread_handle[i]);
9197
}

0 commit comments

Comments
 (0)