- SCM_ASSERT (SCM_NIMP (t) && SCM_THREADP (t), t, SCM_ARG1, s_join_thread);
- coop_join (SCM_THREAD_DATA (t));
+ coop_t *thread_data;
+ SCM_VALIDATE_THREAD (1, thread);
+ /* Dirk:FIXME:: SCM_THREAD_DATA is a handle for a thread. It may be that a
+ * certain thread implementation uses a value of 0 as a valid thread handle.
+ * With the following code, this thread would always be considered finished.
+ */
+ /* Dirk:FIXME:: With preemptive threading, a thread may finish immediately
+ * after SCM_THREAD_DATA is read. Thus, it must be guaranteed that the
+ * handle remains valid until the thread-object is garbage collected, or
+ * a mutex has to be used for reading and modifying SCM_THREAD_DATA.
+ */
+ thread_data = SCM_THREAD_DATA (thread);
+ if (thread_data)
+ /* The thread is still alive */
+ coop_join (thread_data);