Index: /trunk/include/cf_error.h
===================================================================
--- /trunk/include/cf_error.h	(revision 121)
+++ /trunk/include/cf_error.h	(revision 122)
@@ -54,10 +54,11 @@
 /*------------------------------------------------------------*/
 #define CF_ERROR_THREAD_CREATE_CTX			CF_ERROR_THREAD - 1
-#define CF_ERROR_THREAD_CREATE				CF_ERROR_THREAD - 2
-#define CF_ERROR_THREAD_INVALID_ARGS		CF_ERROR_THREAD - 3
-#define CF_ERROR_THREAD_INIT_ATTR			CF_ERROR_THREAD - 4
-#define CF_ERROR_THREAD_SET_INHERIT_SCHED	CF_ERROR_THREAD - 5
-#define CF_ERROR_THREAD_SET_SCHED_POLICY	CF_ERROR_THREAD - 6
-#define CF_ERROR_THREAD_SET_SCHED_PARAM		CF_ERROR_THREAD - 7
+#define CF_ERROR_THREAD_START				CF_ERROR_THREAD - 2
+#define CF_ERROR_THREAD_INVALID_CTX			CF_ERROR_THREAD - 3
+#define CF_ERROR_THREAD_INVALID_ARGS		CF_ERROR_THREAD - 4
+#define CF_ERROR_THREAD_INIT_ATTR			CF_ERROR_THREAD - 5
+#define CF_ERROR_THREAD_SET_INHERIT_SCHED	CF_ERROR_THREAD - 6
+#define CF_ERROR_THREAD_SET_SCHED_POLICY	CF_ERROR_THREAD - 7
+#define CF_ERROR_THREAD_SET_SCHED_PARAM		CF_ERROR_THREAD - 8
 /* }}} thread */
 
@@ -65,6 +66,7 @@
 #define CF_ERROR_MUTEX						CF_ERROR_BASE * 5
 /*------------------------------------------------------------*/
-#define CF_ERROR_MUTEX_CREATE				CF_ERROR_MUTEX - 1
-#define CF_ERROR_MUTEX_INVALID_ARGS			CF_ERROR_MUTEX - 2
+#define CF_ERROR_MUTEX_CREATE_CTX			CF_ERROR_MUTEX - 1
+#define CF_ERROR_MUTEX_CREATE				CF_ERROR_MUTEX - 2
+#define CF_ERROR_MUTEX_INVALID_CTX			CF_ERROR_MUTEX - 3
 /* }}} mutex */
 
Index: /trunk/include/cf_thread.h
===================================================================
--- /trunk/include/cf_thread.h	(revision 121)
+++ /trunk/include/cf_thread.h	(revision 122)
@@ -15,8 +15,8 @@
 typedef int (* CF_Thread_Function) (void *);
 
-/** 스레드 아이디 */
+/** 스레드 컨텍스트 */
 typedef void *	CF_Thread_Ctx;
 
-/** 뮤텍스 아이디 */
+/** 뮤텍스 컨텍스트 */
 typedef void *	CF_Mutex_Ctx;
 
@@ -26,25 +26,28 @@
 
 CF_EXPORT int
-CF_Thread_Create		(CF_Thread_Ctx		* threadID,
+CF_Thread_CreateCtx		(CF_Thread_Ctx		* ctx,
 						 CF_Thread_Function	callback,
 						 void				* arg);
 
 CF_EXPORT int
-CF_Thread_DestroyCtx	(CF_Thread_Ctx * threadID);
+CF_Thread_Start			(CF_Thread_Ctx ctx);
 
 CF_EXPORT int
-CF_Thread_Join			(CF_Thread_Ctx * threadID);
+CF_Thread_DestroyCtx	(CF_Thread_Ctx ctx);
 
 CF_EXPORT int
-CF_Mutex_CreateCtx		(CF_Mutex_Ctx * mutex);
+CF_Thread_Join			(CF_Thread_Ctx ctx);
 
 CF_EXPORT int
-CF_Mutex_DestoryCtx		(CF_Mutex_Ctx * mutex);
+CF_Mutex_CreateCtx		(CF_Mutex_Ctx * ctx);
 
 CF_EXPORT int
-CF_Mutex_Lock			(CF_Mutex_Ctx * mutex);
+CF_Mutex_DestoryCtx		(CF_Mutex_Ctx ctx);
 
 CF_EXPORT int
-CF_Mutex_Unlock			(CF_Mutex_Ctx * mutex);
+CF_Mutex_Lock			(CF_Mutex_Ctx ctx);
+
+CF_EXPORT int
+CF_Mutex_Unlock			(CF_Mutex_Ctx ctx);
 
 #ifdef __cplusplus
Index: /trunk/src/cf_log.c
===================================================================
--- /trunk/src/cf_log.c	(revision 121)
+++ /trunk/src/cf_log.c	(revision 122)
@@ -52,6 +52,6 @@
 		return CF_ERROR_LOG_NOT_MAPPED_ID
 
-#define LOCK_LOG_CTX(__ctx)				CF_Mutex_Lock (&__ctx->mutex)
-#define UNLOCK_LOG_CTX(__ctx)			CF_Mutex_Unlock (&__ctx->mutex)
+#define LOCK_LOG_CTX(__ctx)				CF_Mutex_Lock (__ctx->mutex)
+#define UNLOCK_LOG_CTX(__ctx)			CF_Mutex_Unlock (__ctx->mutex)
 
 #define LOG_BUFFER_DEFAULT_SIZE			128 * 1024
@@ -76,5 +76,6 @@
 
 /** 로그 컨텍스트 (CF_Log_Ctx의 구현) */
-typedef struct __cf_log_ctx__ {
+typedef struct __cf_log_ctx__
+{
 	char			path[NAME_LENGTH + 1];
 	int				fd;
@@ -85,5 +86,6 @@
 } CF_LOG_CTX;
 
-typedef struct __cf_log_array__ {
+typedef struct __cf_log_array__
+{
 	CF_Log_Ctx	* ctxPool;
 	int			ctxSize;
@@ -278,6 +280,8 @@
 	ASSERT_CTX (ctx);
 
-	if (CF_Mutex_DestoryCtx (&context->mutex) < 0)
+	if (CF_Mutex_DestoryCtx (context->mutex) < 0)
 		return CF_ERROR_LOG_UNSET_MULTITHREAD;
+
+	context->mutex = NULL;
 
 	return CF_OK;
@@ -370,5 +374,5 @@
 	CF_File_Close (context->fd);
 
-	CF_Mutex_DestoryCtx (&context->mutex);
+	CF_Mutex_DestoryCtx (context->mutex);
 	context->mutex = NULL;
 
@@ -381,14 +385,14 @@
  * \return 성공 시, 로그 컨텍스트; 실패 시, NULL
  *
+ * \param ctx		로그 컨텍스트 주소
  * \param path		로그 파일 경로
  * \param memsize	로그 버퍼 크기
- * \param ctx		로그 컨텍스트 받을 주소
  *
  * \see CF_LOG_DEFAULT_BUFFER, CF_LOG_NO_BUFFER
  */
 static int
-CF_Log_CreateCtx (const char	* path,
-				  const int		memsize,
-				  CF_Log_Ctx	* ctx)
+CF_Log_CreateCtx (CF_Log_Ctx	* ctx,
+				  const char	* path,
+				  const int		memsize)
 {
 	int result = 0;
@@ -580,5 +584,5 @@
 	CF_Log_Ctx	ctx = NULL;
 
-	result = CF_Log_CreateCtx (path, memsize, &ctx);
+	result = CF_Log_CreateCtx (&ctx, path, memsize);
 	if (result < 0)
 		return result;
Index: /trunk/src/cf_thread.c
===================================================================
--- /trunk/src/cf_thread.c	(revision 121)
+++ /trunk/src/cf_thread.c	(revision 122)
@@ -26,37 +26,85 @@
 #endif // #if defined(_WIN32) || defined(_WIN64)
 
-#define ASSERT_THREAD(__h)	\
-	if (__h == NULL)		\
-		return CF_ERROR_THREAD_INVALID_ARGS
-
-#define ASSERT_MUTEX(__h)	\
-	if (__h == NULL)		\
-		return CF_ERROR_MUTEX_INVALID_ARGS
+#define ASSERT_THREAD_CTX(__ctx)	\
+	if (__ctx == NULL)				\
+		return CF_ERROR_THREAD_INVALID_CTX
+
+#define ASSERT_MUTEX_CTX(__ctx)	\
+	if (__ctx == NULL)			\
+		return CF_ERROR_MUTEX_INVALID_CTX
 
 typedef THREAD_RETURN (THREAD_CALL * THREAD_WORKER) (void *);
 
+typedef struct __cf_thread_ctx__
+{
+	THREAD_TYPE		tid;
+	THREAD_WORKER	callback;
+	void			* arg;
+} CF_THREAD_CTX;
+
+typedef struct __cf_ctx_ctx__
+{
+	MUTEX_TYPE	mid;
+} CF_MUTEX_CTX;
+
 static int
-CF_Thread_Local_Close (void * ctx)
-{
-#if defined(_WIN32) || defined(_WIN64)
-	CloseHandle (ctx);
-#else
-	free (ctx);
-#endif
-
-	return CF_OK;
-}
-
-/**
- * 스레드를 생성
- *
- * \return 성공 시, CF_OK; 실패 시, 오류 코드
- *
- * \param threadID	스레드 아이디 주소
+CF_Thread_Local_Close (THREAD_TYPE tid)
+{
+#if defined(_WIN32) || defined(_WIN64)
+	CloseHandle (tid);
+#endif
+
+	return CF_OK;
+}
+
+static int
+CF_Mutex_Local_Close (MUTEX_TYPE mid)
+{
+#if defined(_WIN32) || defined(_WIN64)
+	CloseHandle (mid);
+#else
+	pthread_mutex_destroy (&mid);
+#endif
+
+	return CF_OK;
+}
+
+/**
+ * 스레드 컨텍스트를 생성
+ *
+ * \return 성공 시, CF_OK; 실패 시, 오류 코드
+ *
+ * \param ctx		스레드 컨텍스트 주소
  * \param callback	스레드 워커 함수 이름
  * \param arg		스레드 함수로 전달할 인자
+ */
+int
+CF_Thread_CreateCtx (CF_Thread_Ctx		* ctx,
+					 CF_Thread_Function	callback,
+					 void				* arg)
+{
+	CF_THREAD_CTX * context = NULL;
+
+	context = (CF_THREAD_CTX *) calloc (sizeof (CF_THREAD_CTX), 1);
+	if (context == NULL)
+		return CF_ERROR_THREAD_CREATE_CTX;
+
+	context->callback	= (THREAD_WORKER) callback;
+	context->arg		= arg;
+
+	*ctx = (CF_Thread_Ctx) context;
+
+	return CF_OK;
+}
+
+/**
+ * 스레드를 실행
+ *
+ * \return 성공 시, CF_OK; 실패 시, 오류 코드
+ *
+ * \param ctx 스레드 컨텍스트
  *
  * \remarks
- * pthread(POSIX Thread)에서 지원되는 스케줄링 정책은 SCHED_OTHER, SCHED_FIFO, SCHED_RR 등이 존재 <br />
+ * pthread에서 지원되는 스케줄링 정책은 SCHED_OTHER, SCHED_FIFO, SCHED_RR 등이 존재 <br />
  * 일반적으로 설정되는 스케줄링 정책의 기본값은 SCHED_OTHER이며, 솔라리스 환경에서 SCHED_OTHER는 TS(timesharing) 방식으로 명시되어 있음 <br />
  * 그러나 개발 단계에서 테스트된 동작은 SCHED_FIFO와 동일하였으며, 때문에 솔라리스 환경에서는 스케줄링 정책을 SCHED_RR로 명시하도록 함 <br />
@@ -67,16 +115,16 @@
  */
 int
-CF_Thread_Create (CF_Thread_Ctx			* threadID,
-				  CF_Thread_Function	callback,
-				  void					* arg)
+CF_Thread_Start (CF_Thread_Ctx ctx)
 {
 	int result = 0;
 
-	THREAD_WORKER f = (THREAD_WORKER) callback;
-
-#if defined(_WIN32) || defined(_WIN64)
-	*threadID = (THREAD_TYPE) CreateThread (NULL, 0, f, arg, 0, NULL);
-	if (*threadID == NULL)
-		return CF_ERROR_THREAD_CREATE;
+	CF_THREAD_CTX * context = (CF_THREAD_CTX *) ctx;
+
+	ASSERT_THREAD_CTX (ctx);
+
+#if defined(_WIN32) || defined(_WIN64)
+	context->tid = CreateThread (NULL, 0, context->callback, context->arg, 0, NULL);
+	if (context->tid == NULL)
+		return CF_ERROR_THREAD_START;
 #else
 
@@ -106,106 +154,120 @@
 # endif // # if defined(_SOLARIS)
 
-	*threadID = (THREAD_TYPE *) calloc (sizeof (THREAD_TYPE), 1);
-	if (*threadID == NULL)
-		return CF_ERROR_THREAD_CREATE_CTX;
-
-	result = pthread_create ((THREAD_TYPE *) *threadID, attr, f, arg);
-	if (result)
+	result = pthread_create (&context->tid, attr, context->callback, context->arg);
+	if (result)
+		return CF_ERROR_THREAD_START;
+#endif
+	return result;
+}
+
+/**
+ * 스레드 컨텍스트를 해제
+ *
+ * \return 성공 시, CF_OK; 실패 시, 오류 코드
+ *
+ * \param ctx 스레드 컨텍스트
+ *
+ * \remarks 스레드 컨텍스트를 해제하는 것이며 워커 스레드가 종료되지 않음
+ */
+int
+CF_Thread_DestroyCtx (CF_Thread_Ctx ctx)
+{
+	CF_THREAD_CTX * context = (CF_THREAD_CTX *) ctx;
+
+	ASSERT_THREAD_CTX (ctx);
+
+	CF_Thread_Local_Close (context->tid);
+	free (context);
+
+	return CF_OK;
+}
+
+/**
+ * 스레드가 종료될 때 까지 대기
+ *
+ * \return CF_OK 반환
+ *
+ * \param ctx 스레드 컨텍스트
+ */
+int
+CF_Thread_Join (CF_Thread_Ctx ctx)
+{
+	CF_THREAD_CTX * context = (CF_THREAD_CTX *) ctx;
+
+	char status[16] = {0x00,};
+
+	ASSERT_THREAD_CTX (ctx);
+
+#if defined(_WIN32) || defined(_WIN64)
+	WaitForSingleObject (context->tid, INFINITE);
+#else
+	pthread_join (context->tid, (void **)status);
+#endif
+
+	return CF_OK;
+}
+
+/**
+ * 뮤텍스 컨텍스트를 생성
+ *
+ * \return 성공 시, CF_OK; 실패 시, 오류 코드
+ *
+ * \param ctx 뮤텍스 컨텍스트 주소
+ */
+int
+CF_Mutex_CreateCtx (CF_Mutex_Ctx * ctx)
+{
+	int result = 0;
+
+	CF_MUTEX_CTX * context = NULL;
+
+	context = (CF_MUTEX_CTX *) calloc (sizeof (CF_MUTEX_CTX), 1);
+	if (context == NULL)
+		return CF_ERROR_MUTEX_CREATE_CTX;
+
+	TRY
 	{
-		CF_Thread_DestroyCtx (threadID);
-		return CF_ERROR_THREAD_CREATE;
+#if defined(_WIN32) || defined(_WIN64)
+		context->mid = CreateMutexA (NULL, FALSE, NULL);
+		if (*ctx == NULL)
+		{
+			result = CF_ERROR_MUTEX_CREATE;
+			TRY_BREAK;
+		}
+#else
+		result = pthread_mutex_init (&context->mid, NULL);
+		if (result)
+		{
+			result = CF_ERROR_MUTEX_CREATE;
+			TRY_BREAK;
+		}
+#endif
 	}
-
-#endif
-	return result;
-}
-
-/**
- * 스레드 아이디를 해제
- *
- * \return 성공 시, CF_OK; 실패 시, 오류 코드
- *
- * \param threadID 스레드 아이디 주소
- *
- * \remarks 스레드 아이디를 해제하는 것이며 워커 스레드가 종료되지 않음
- */
-int
-CF_Thread_DestroyCtx (CF_Thread_Ctx * threadID)
-{
-	ASSERT_THREAD (*threadID);
-
-	return CF_Thread_Local_Close (*threadID);
-}
-
-/**
- * 스레드가 종료될 때 까지 대기
- *
- * \return CF_OK 반환
- *
- * \param threadID 스레드 아이디 주소
- */
-int
-CF_Thread_Join (CF_Thread_Ctx * threadID)
-{
-	ASSERT_THREAD (*threadID);
-
-#if defined(_WIN32) || defined(_WIN64)
-	WaitForSingleObject ((THREAD_TYPE) *threadID, INFINITE);
-#else
-	char status[16] = {0x00,};
-	pthread_join (*((THREAD_TYPE *) *threadID), (void **)status);
-#endif
-
-	return CF_OK;
-}
-
-/**
- * 뮤텍스 생성
- *
- * \return 성공 시, CF_OK; 실패 시, 오류 코드
- *
- * \param mutex 뮤텍스 아이디 주소
- *
- * \see CF_Thread_Create
- */
-int
-CF_Mutex_CreateCtx (CF_Mutex_Ctx * mutex)
-{
-	int result = 0;
-
-#if defined(_WIN32) || defined(_WIN64)
-	*mutex = (MUTEX_TYPE) CreateMutexA (NULL, FALSE, NULL);
-	if (*mutex == NULL)
-		return CF_ERROR_MUTEX_CREATE;
-#else
-	*mutex = (MUTEX_TYPE *) calloc (sizeof (MUTEX_TYPE), 1);
-	if (*mutex == NULL)
-		return CF_ERROR_MUTEX_CREATE;
-
-	result = pthread_mutex_init (*mutex, NULL);
-	if (result)
-		return CF_ERROR_MUTEX_CREATE;
-#endif
-
-	return CF_OK;
-}
-
-/**
- * 뮤텍스 해제
- *
- * \return 성공 시, CF_OK; 실패 시, 오류 코드
- *
- * \param mutex 뮤텍스 아이디 주소
- */
-int
-CF_Mutex_DestoryCtx (CF_Mutex_Ctx * mutex)
-{
-	ASSERT_MUTEX (*mutex);
-
-#if defined(_WIN32) || defined(_WIN64)
-#else
-	pthread_mutex_destroy (*mutex);
-#endif
-	return CF_Thread_Local_Close (*mutex);
+	CATCH_IF (result < 0)
+	{
+		CF_Mutex_DestoryCtx (ctx);
+	}
+
+	return CF_OK;
+}
+
+/**
+ * 뮤텍스 컨텍스트 해제
+ *
+ * \return 성공 시, CF_OK; 실패 시, 오류 코드
+ *
+ * \param ctx 뮤텍스 컨텍스트
+ */
+int
+CF_Mutex_DestoryCtx (CF_Mutex_Ctx ctx)
+{
+	CF_MUTEX_CTX * context = ctx;
+
+	ASSERT_MUTEX_CTX (ctx);
+
+	CF_Mutex_Local_Close (context->mid);
+	free (context);
+
+	return CF_OK;
 }
 
@@ -215,15 +277,17 @@
  * \return 성공 시, CF_OK; 실패 시, 오류 코드
  *
- * \param mutex 뮤텍스 아이디 주소
- */
-int
-CF_Mutex_Lock (CF_Mutex_Ctx * mutex)
-{
-	ASSERT_MUTEX (*mutex);
-
-#if defined(_WIN32) || defined(_WIN64)
-	WaitForSingleObject ((MUTEX_TYPE) *mutex, INFINITE);
-#else
-	pthread_mutex_lock ((MUTEX_TYPE *) *mutex);
+ * \param ctx 뮤텍스 컨텍스트
+ */
+int
+CF_Mutex_Lock (CF_Mutex_Ctx ctx)
+{
+	CF_MUTEX_CTX * context = ctx;
+
+	ASSERT_MUTEX_CTX (ctx);
+
+#if defined(_WIN32) || defined(_WIN64)
+	WaitForSingleObject (context->mid, INFINITE);
+#else
+	pthread_mutex_lock (&context->mid);
 #endif
 
@@ -236,17 +300,19 @@
  * \return 성공 시, CF_OK; 실패 시, 오류 코드
  *
- * \param mutex 뮤텍스 아이디 주소
- */
-int
-CF_Mutex_Unlock (CF_Mutex_Ctx * mutex)
-{
-	ASSERT_MUTEX (*mutex);
-
-#if defined(_WIN32) || defined(_WIN64)
-	ReleaseMutex (*mutex);
-#else
-	pthread_mutex_unlock ((MUTEX_TYPE *) *mutex);
-#endif
-
-	return CF_OK;
-}
+ * \param ctx 뮤텍스 컨텍스트
+ */
+int
+CF_Mutex_Unlock (CF_Mutex_Ctx ctx)
+{
+	CF_MUTEX_CTX * context = ctx;
+
+	ASSERT_MUTEX_CTX (ctx);
+
+#if defined(_WIN32) || defined(_WIN64)
+	ReleaseMutex (context->mid);
+#else
+	pthread_mutex_unlock (&context->mid);
+#endif
+
+	return CF_OK;
+}
Index: /trunk/test/log.c
===================================================================
--- /trunk/test/log.c	(revision 121)
+++ /trunk/test/log.c	(revision 122)
@@ -85,5 +85,5 @@
 	for (i = 0 ; i < 10 ; i++)
 	{
-		if (CF_Thread_Create (&tid[i], test_log_mt, &i) < 0)
+		if (CF_Thread_CreateCtx (&tid[i], test_log_mt, &i) < 0)
 		{
 			CF_DEBUG_PRINT (stderr, "failed to create %dth thread\n", i);
@@ -94,11 +94,20 @@
 	for (i = 0 ; i < 10 ; i++)
 	{
-		if (CF_Thread_Join (&tid[i]) < 0)
+		if (CF_Thread_Start (tid[i]) < 0)
+		{
+			CF_DEBUG_PRINT (stderr, "failed to start %dth thread\n", i);
+			return -3;
+		}
+	}
+
+	for (i = 0 ; i < 10 ; i++)
+	{
+		if (CF_Thread_Join (tid[i]) < 0)
 			CF_DEBUG_PRINT (stderr, "failed to join %dth thread\n", i);
-		if (CF_Thread_DestroyCtx (&tid[i]) < 0)
+		if (CF_Thread_DestroyCtx (tid[i]) < 0)
 			CF_DEBUG_PRINT (stderr, "failed to release %dth thread\n", i);
 	}
 
-	if (CF_Mutex_DestoryCtx (&globalMutex) < 0) {
+	if (CF_Mutex_DestoryCtx (globalMutex) < 0) {
 		// error
 	}
Index: /trunk/test/socket.c
===================================================================
--- /trunk/test/socket.c	(revision 121)
+++ /trunk/test/socket.c	(revision 122)
@@ -135,5 +135,5 @@
 	for (iter = 0 ; iter < THREAD_POOL ; iter++)
 	{
-		if (CF_Thread_Create (&stid[iter], socket_echo_server, &sock) < 0)
+		if (CF_Thread_CreateCtx (&stid[iter], socket_echo_server, &sock) < 0)
 		{
 			CF_DEBUG_PRINT (stderr, "failed to create %dth thread\n", iter);
@@ -145,5 +145,5 @@
 	for (iter = 0 ; iter < THREAD_POOL ; iter++)
 	{
-		if (CF_Thread_Create (&ctid[iter], socket_echo_client, &sock) < 0)
+		if (CF_Thread_CreateCtx (&ctid[iter], socket_echo_client, &sock) < 0)
 		{
 			CF_DEBUG_PRINT (stderr, "failed to create %dth thread\n", iter);
@@ -155,9 +155,27 @@
 	for (iter = 0 ; iter < THREAD_POOL ; iter++)
 	{
-		CF_Thread_Join (&ctid[iter]);
-		CF_Thread_DestroyCtx (&ctid[iter]);
+		if (CF_Thread_Start (stid[iter]) < 0)
+		{
+			CF_DEBUG_PRINT (stderr, "failed to start %dth thread\n", iter);
+			return -6;
+		}
+	}
 
-		CF_Thread_Join (&stid[iter]);
-		CF_Thread_DestroyCtx (&stid[iter]);
+	for (iter = 0 ; iter < THREAD_POOL ; iter++)
+	{
+		if (CF_Thread_Start (ctid[iter]) < 0)
+		{
+			CF_DEBUG_PRINT (stderr, "failed to start %dth thread\n", iter);
+			return -7;
+		}
+	}
+
+	for (iter = 0 ; iter < THREAD_POOL ; iter++)
+	{
+		CF_Thread_Join (ctid[iter]);
+		CF_Thread_DestroyCtx (ctid[iter]);
+
+		CF_Thread_Join (stid[iter]);
+		CF_Thread_DestroyCtx (stid[iter]);
 
 		CF_Log_Write (LOG_SOCKET, "SOCKET", "join server thread-%d\n", iter);
Index: /trunk/test/thread.c
===================================================================
--- /trunk/test/thread.c	(revision 121)
+++ /trunk/test/thread.c	(revision 122)
@@ -32,5 +32,5 @@
 
 	for (i = 0 ; i < 10 ; i++) {
-		if (CF_Thread_Create (&tid[i], worker, NULL) < 0) {
+		if (CF_Thread_CreateCtx (&tid[i], worker, NULL) < 0) {
 			// error
 		}
@@ -38,5 +38,5 @@
 
 	for (i = 0 ; i < 10 ; i++) {
-		if (CF_Thread_Join (&tid[i]) < 0) { // block
+		if (CF_Thread_Start (tid[i]) < 0) {
 			// error
 		}
@@ -44,10 +44,16 @@
 
 	for (i = 0 ; i < 10 ; i++) {
-		if (CF_Thread_DestroyCtx (&tid[i]) < 0) {
+		if (CF_Thread_Join (tid[i]) < 0) { // block
 			// error
 		}
 	}
 
-	if (CF_Mutex_DestoryCtx (&globalMutex) < 0) {
+	for (i = 0 ; i < 10 ; i++) {
+		if (CF_Thread_DestroyCtx (tid[i]) < 0) {
+			// error
+		}
+	}
+
+	if (CF_Mutex_DestoryCtx (globalMutex) < 0) {
 		// error
 	}
