Index: trunk/Include/Classes/System/IO/DirectoryInfo.ab
===================================================================
--- trunk/Include/Classes/System/IO/DirectoryInfo.ab	(revision 329)
+++ trunk/Include/Classes/System/IO/DirectoryInfo.ab	(revision 330)
@@ -165,5 +165,5 @@
 
 		Dim files As List<FileSystemInfo>
-		Dim i As Long
+		Dim i = 0 As Long
 		Do
 			If i > 1 Then
Index: trunk/Include/Classes/System/Threading/Thread.ab
===================================================================
--- trunk/Include/Classes/System/Threading/Thread.ab	(revision 329)
+++ trunk/Include/Classes/System/Threading/Thread.ab	(revision 330)
@@ -26,4 +26,5 @@
 	m_fp As PTHREAD_START_ROUTINE
 	m_args As VoidPtr
+	name As String
 
 Public
@@ -34,4 +35,6 @@
 
 		m_fp=0
+
+		name = "sub thread"
 	End Sub
 	Sub Thread(fp As PTHREAD_START_ROUTINE, args As VoidPtr)
@@ -42,4 +45,6 @@
 		m_fp=fp
 		m_args=args
+
+		name = "sub thread"
 	End Sub
 
@@ -50,4 +55,6 @@
 		m_fp=obj.m_fp
 		m_args=obj.m_args
+
+		name = "sub thread"
 	End Sub
 
@@ -55,4 +62,6 @@
 		m_hThread=hThread
 		m_dwThreadId=dwThreadId
+
+		name = "sub thread"
 	End Sub
 
@@ -83,4 +92,11 @@
 		Return m_dwThreadId
 	End Function
+
+	Function Name() As String
+		Return name
+	End Function
+	Sub Name( name As String )
+		This.name = name
+	End Sub
 
 
Index: trunk/Include/system/gc.sbp
===================================================================
--- trunk/Include/system/gc.sbp	(revision 329)
+++ trunk/Include/system/gc.sbp	(revision 330)
@@ -126,4 +126,5 @@
 		' 自身のThreadオブジェクトを生成
 		Dim thread As Thread(hTargetThread,GetCurrentThreadId(),0)
+		thread.Name = "main"
 
 		_System_pobj_AllThreads->BeginThread(ObjPtr( thread ),_System_gc_StackRoot_StartPtr As *LONG_PTR)
@@ -179,4 +180,11 @@
 			pdwFlags[n]=flags
 		LeaveCriticalSection(CriticalSection)
+
+		/*
+		' デバッグ用
+		If n = 1996 Then
+			debug
+		End If
+		*/
 
 		n++
@@ -283,4 +291,10 @@
 		End If
 
+		/*
+		_System_DebugOnly_OutputDebugString( "  (scanning object)" )
+		_System_DebugOnly_OutputDebugString( classTypeInfo.Name )
+		_System_DebugOnly_OutputDebugString( Ex"\r\n" )
+		*/
+
 		Dim i As Long
 		For i = 0 To ELM(classTypeInfo.numOfReference)
@@ -330,8 +344,9 @@
 		Dim i As Long
 		For i=0 To ELM(_System_pobj_AllThreads->ThreadNum)
-			If _System_pobj_AllThreads->ppobj_Thread[i] Then
+			Dim thread = _System_pobj_AllThreads->ppobj_Thread[i]
+			If thread Then
 				FillMemory(VarPtr(Context),SizeOf(CONTEXT),0)
 				Context.ContextFlags=CONTEXT_CONTROL
-				If _System_pobj_AllThreads->ppobj_Thread[i]->__GetContext(Context)=0 Then
+				If thread->__GetContext(Context)=0 Then
 					_System_DebugOnly_OutputDebugString(Ex"レジスタ情報の取得に失敗しました。\r\n")
 				End If
@@ -350,4 +365,10 @@
 					Exit Sub
 				End If
+
+				/*
+				_System_DebugOnly_OutputDebugString( "(scanning thread local)" )
+				_System_DebugOnly_OutputDebugString( thread.Name )
+				_System_DebugOnly_OutputDebugString( Ex"\r\n" )
+				*/
 
 				Scan( NowSp, maxNum, pbMark )
