return;
if (!gc_disabled) {
+
+ /* Stop all worker threads before signalling the finalizer to stop
+ * That way the finalizer has a chance to clean up the worker threads */
+ mono_gc_base_cleanup ();
+
finished = TRUE;
if (mono_thread_internal_current () != gc_thread) {
int ret;
ret = guarded_wait (gc_thread->handle, MONO_INFINITE_WAIT, FALSE);
g_assert (ret == MONO_THREAD_INFO_WAIT_RET_SUCCESS_0);
- mono_thread_join (GUINT_TO_POINTER (gc_thread->tid));
+ /* Clean up the finalizer (and other threads that might still wait to be joined) */
+ mono_threads_join_threads ();
break;
}
g_assert (ret == MONO_THREAD_INFO_WAIT_RET_SUCCESS_0);
- mono_thread_join (GUINT_TO_POINTER (gc_thread->tid));
+ /* Clean up the finalizer (and other threads that might still wait to be joined) */
+ mono_threads_join_threads ();
break;
}
}
}
gc_thread = NULL;
- mono_gc_base_cleanup ();
}
mono_reference_queue_cleanup ();
mono_os_mutex_destroy (&lock);
mono_os_cond_destroy (&work_cond);
mono_os_cond_destroy (&done_cond);
+
+ for (int i = 0; i < threads_num; i++) {
+ mono_threads_add_joinable_thread ((gpointer)threads [i]);
+ }
}
SgenThreadPoolJob*