Index: src/org/armedbear/lisp/with-mutex.lisp
===================================================================
--- src/org/armedbear/lisp/with-mutex.lisp	(revision 12040)
+++ src/org/armedbear/lisp/with-mutex.lisp	(working copy)
@@ -29,7 +29,7 @@
 ;;; obligated to do so.  If you do not wish to do so, delete this
 ;;; exception statement from your version.
 
-(in-package #:extensions)
+(in-package "THREADS")
 
 (defmacro with-mutex ((mutex) &body body)
   (let ((m (gensym)))
Index: src/org/armedbear/lisp/Utilities.java
===================================================================
--- src/org/armedbear/lisp/Utilities.java	(revision 12040)
+++ src/org/armedbear/lisp/Utilities.java	(working copy)
@@ -50,7 +50,7 @@
             osName.startsWith("NetBSD");
         isPlatformWindows = osName.startsWith("Windows");
     }
-
+    
     public static boolean isFilenameAbsolute(String filename)
     {
         final int length = filename.length();
Index: src/org/armedbear/lisp/with-thread-lock.lisp
===================================================================
--- src/org/armedbear/lisp/with-thread-lock.lisp	(revision 12040)
+++ src/org/armedbear/lisp/with-thread-lock.lisp	(working copy)
@@ -29,7 +29,7 @@
 ;;; obligated to do so.  If you do not wish to do so, delete this
 ;;; exception statement from your version.
 
-(in-package "EXTENSIONS")
+(in-package "THREADS")
 
 (defmacro with-thread-lock ((lock) &body body)
   (let ((glock (gensym)))
Index: src/org/armedbear/lisp/Gate.java
===================================================================
--- src/org/armedbear/lisp/Gate.java	(revision 12040)
+++ src/org/armedbear/lisp/Gate.java	(working copy)
@@ -101,7 +101,7 @@
 
   // ### make-gate => gate
   private static final Primitive MAKE_GATE 
-    = new Primitive("make-gate", PACKAGE_EXT, true, "openp",
+    = new Primitive("make-gate", PACKAGE_THREADS, true, "openp",
 		    "Creates a gate with initial state OPENP.") {
 	@Override
 	public LispObject execute(LispObject arg) 
@@ -113,7 +113,7 @@
 
   // ### open-gate-p gate => generalized-boolean
   private static final Primitive OPEN_GATE_P 
-    = new Primitive("open-gate-p", PACKAGE_EXT, true, "gate",
+    = new Primitive("open-gate-p", PACKAGE_THREADS, true, "gate",
 		    "Boolean predicate as to whether GATE is open or not.") {
       @Override
       public LispObject execute(LispObject arg) 
@@ -127,7 +127,7 @@
 
   // ### open-gate gate => generalized-boolean
   private static final Primitive OPEN_GATE 
-    = new Primitive("open-gate", PACKAGE_EXT, true, "gate",
+    = new Primitive("open-gate", PACKAGE_THREADS, true, "gate",
 		    "Makes the state of GATE open.")
     {
       @Override
@@ -141,7 +141,7 @@
 
   // ### close-gate gate
   private static final Primitive CLOSE_GATE 
-    = new Primitive("close-gate", PACKAGE_EXT, true, "gate",
+    = new Primitive("close-gate", PACKAGE_THREADS, true, "gate",
 		    "Makes the state of GATE closed.") {
       @Override
       public LispObject execute(LispObject arg) 
@@ -156,7 +156,7 @@
 
   // ### wait-open-gate gate
   private static final Primitive WAIT_OPEN_GATE 
-    = new Primitive("wait-open-gate", PACKAGE_EXT, true, 
+    = new Primitive("wait-open-gate", PACKAGE_THREADS, true, 
 		    "gate &optional timeout",
 		    "Wait for GATE to be open with an optional TIMEOUT in seconds." ) {
 	@Override
Index: src/org/armedbear/lisp/Lisp.java
===================================================================
--- src/org/armedbear/lisp/Lisp.java	(revision 12040)
+++ src/org/armedbear/lisp/Lisp.java	(working copy)
@@ -94,6 +94,11 @@
         PACKAGE_CL_USER.usePackage(PACKAGE_CL);
         PACKAGE_CL_USER.usePackage(PACKAGE_EXT);
         PACKAGE_CL_USER.usePackage(PACKAGE_JAVA);
+        PACKAGE_CL_USER.usePackage(PACKAGE_THREADS);
+
+        // FIXME: The following packages all have to use EXT because
+        // of EXT:AUTOLOAD and autoload.lisp.
+
         PACKAGE_SYS.addNickname("SYS");
         PACKAGE_SYS.usePackage(PACKAGE_CL);
         PACKAGE_SYS.usePackage(PACKAGE_EXT);
@@ -105,6 +110,7 @@
         PACKAGE_TPL.usePackage(PACKAGE_EXT);
         PACKAGE_EXT.addNickname("EXT");
         PACKAGE_EXT.usePackage(PACKAGE_CL);
+        // FIXME: To be removed.
         PACKAGE_EXT.usePackage(PACKAGE_THREADS);
         PACKAGE_JVM.usePackage(PACKAGE_CL);
         PACKAGE_JVM.usePackage(PACKAGE_EXT);
@@ -118,6 +124,8 @@
         PACKAGE_LISP.usePackage(PACKAGE_CL);
         PACKAGE_LISP.usePackage(PACKAGE_EXT);
         PACKAGE_LISP.usePackage(PACKAGE_SYS);
+        PACKAGE_THREADS.usePackage(PACKAGE_CL);
+        PACKAGE_THREADS.usePackage(PACKAGE_EXT);
       }
     catch (Throwable t)
       {
Index: src/org/armedbear/lisp/ThreadLock.java
===================================================================
--- src/org/armedbear/lisp/ThreadLock.java	(revision 12040)
+++ src/org/armedbear/lisp/ThreadLock.java	(working copy)
@@ -72,7 +72,7 @@
 
     // ### make-thread-lock
     private static final Primitive MAKE_THREAD_LOCK =
-        new Primitive("make-thread-lock", PACKAGE_EXT, true)
+        new Primitive("make-thread-lock", PACKAGE_THREADS, true)
     {
         @Override
         public LispObject execute() throws ConditionThrowable
@@ -83,7 +83,7 @@
 
     // ### thread-lock lock
     private static final Primitive THREAD_LOCK =
-        new Primitive("thread-lock", PACKAGE_EXT, true)
+        new Primitive("thread-lock", PACKAGE_THREADS, true)
     {
         @Override
         public LispObject execute(LispObject arg) throws ConditionThrowable
@@ -96,7 +96,7 @@
 
     // ### thread-unlock lock
     private static final Primitive THREAD_UNLOCK =
-        new Primitive("thread-unlock", PACKAGE_EXT, true)
+        new Primitive("thread-unlock", PACKAGE_THREADS, true)
     {
         @Override
         public LispObject execute(LispObject arg) throws ConditionThrowable
Index: src/org/armedbear/lisp/Autoload.java
===================================================================
--- src/org/armedbear/lisp/Autoload.java	(revision 12040)
+++ src/org/armedbear/lisp/Autoload.java	(working copy)
@@ -486,37 +486,40 @@
         autoload("unbound-slot-instance", "unbound_slot_instance");
         autoload("unexport", "PackageFunctions");
         autoload("unuse-package", "PackageFunctions");
+
         autoload(PACKAGE_EXT, "arglist", "arglist", true);
         autoload(PACKAGE_EXT, "assq", "assq", true);
         autoload(PACKAGE_EXT, "assql", "assql", true);
-        autoload(PACKAGE_EXT, "close-gate", "Gate", true);
         autoload(PACKAGE_EXT, "file-directory-p", "probe_file", true);
         autoload(PACKAGE_EXT, "gc", "gc", true);
         autoload(PACKAGE_EXT, "get-floating-point-modes", "FloatFunctions", true);
-        autoload(PACKAGE_EXT, "get-mutex", "Mutex", true);
-	autoload(PACKAGE_EXT, "make-gate", "Gate", true);
         autoload(PACKAGE_EXT, "mailbox-empty-p", "Mailbox", true);
         autoload(PACKAGE_EXT, "mailbox-peek", "Mailbox", true);
         autoload(PACKAGE_EXT, "mailbox-read", "Mailbox", true);
         autoload(PACKAGE_EXT, "mailbox-send", "Mailbox", true);
         autoload(PACKAGE_EXT, "make-mailbox", "Mailbox", true);
-        autoload(PACKAGE_EXT, "make-mutex", "Mutex", true);
         autoload(PACKAGE_EXT, "make-slime-input-stream", "SlimeInputStream", true);
         autoload(PACKAGE_EXT, "make-slime-output-stream", "SlimeOutputStream", true);
-        autoload(PACKAGE_EXT, "make-thread-lock", "ThreadLock", true);
-        autoload(PACKAGE_EXT, "open-gate", "Gate", true);
-        autoload(PACKAGE_EXT, "open-gate-p", "Gate", true);
         autoload(PACKAGE_EXT, "probe-directory", "probe_file", true);
-        autoload(PACKAGE_EXT, "release-mutex", "Mutex", true);
         autoload(PACKAGE_EXT, "set-floating-point-modes", "FloatFunctions", true);
         autoload(PACKAGE_EXT, "simple-string-fill", "StringFunctions");
         autoload(PACKAGE_EXT, "simple-string-search", "StringFunctions");
         autoload(PACKAGE_EXT, "string-input-stream-current", "StringInputStream", true);
         autoload(PACKAGE_EXT, "string-find", "StringFunctions");
         autoload(PACKAGE_EXT, "string-position", "StringFunctions");
-        autoload(PACKAGE_EXT, "thread-lock", "ThreadLock", true);
-        autoload(PACKAGE_EXT, "thread-unlock", "ThreadLock", true);
-        autoload(PACKAGE_EXT, "wait-open-gate", "Gate", true);
+
+        autoload(PACKAGE_THREADS, "make-mutex", "Mutex", true);
+        autoload(PACKAGE_THREADS, "get-mutex", "Mutex", true);
+	autoload(PACKAGE_THREADS, "make-gate", "Gate", true);
+        autoload(PACKAGE_THREADS, "open-gate", "Gate", true);
+        autoload(PACKAGE_THREADS, "open-gate-p", "Gate", true);
+        autoload(PACKAGE_THREADS, "close-gate", "Gate", true);
+        autoload(PACKAGE_THREADS, "release-mutex", "Mutex", true);
+        autoload(PACKAGE_THREADS, "thread-lock", "ThreadLock", true);
+        autoload(PACKAGE_THREADS, "thread-unlock", "ThreadLock", true);
+        autoload(PACKAGE_THREADS, "wait-open-gate", "Gate", true);
+        autoload(PACKAGE_THREADS, "make-thread-lock", "ThreadLock", true);
+
         autoload(PACKAGE_JAVA, "%jnew-proxy", "JProxy");
         autoload(PACKAGE_JAVA, "%find-java-class", "JavaClass");
         autoload(PACKAGE_JAVA, "%jmake-invocation-handler", "JProxy");
@@ -525,13 +528,16 @@
         autoload(PACKAGE_JAVA, "%jredefine-method", "RuntimeClass");
         autoload(PACKAGE_JAVA, "%jregister-handler", "JHandler");
         autoload(PACKAGE_JAVA, "%load-java-class-from-byte-array", "RuntimeClass");
+
         autoload(PACKAGE_MOP, "funcallable-instance-function", "StandardGenericFunction", false);
         autoload(PACKAGE_MOP, "generic-function-name", "StandardGenericFunction", true);
         autoload(PACKAGE_MOP, "method-qualifiers", "StandardMethod", true);
         autoload(PACKAGE_MOP, "method-specializers", "StandardMethod", true);
         autoload(PACKAGE_MOP, "set-funcallable-instance-function", "StandardGenericFunction", true);
+
         autoload(PACKAGE_PROF, "%start-profiler", "Profiler", true);
         autoload(PACKAGE_PROF, "stop-profiler", "Profiler", true);
+
         autoload(PACKAGE_SYS, "%%string=", "StringFunctions");
         autoload(PACKAGE_SYS, "%adjust-array", "adjust_array");
         autoload(PACKAGE_SYS, "%defpackage", "PackageFunctions");
Index: src/org/armedbear/lisp/autoloads.lisp
===================================================================
--- src/org/armedbear/lisp/autoloads.lisp	(revision 12040)
+++ src/org/armedbear/lisp/autoloads.lisp	(working copy)
@@ -293,15 +293,11 @@
 
 (export '(grovel-java-definitions compile-system))
 (autoload '(grovel-java-definitions compile-system) "compile-system")
-(export 'with-thread-lock)
-(autoload-macro 'with-thread-lock)
 (export 'aver)
 (autoload-macro 'aver)
 (autoload 'sys::%failed-aver "aver")
 (export 'collect)
 (autoload-macro 'collect)
-(export 'with-mutex)
-(autoload-macro 'with-mutex)
 (export 'compile-file-if-needed)
 (autoload 'compile-file-if-needed "compile-file")
 (export 'describe-compiler-policy)
@@ -315,7 +311,14 @@
 (export 'make-dialog-prompt-stream)
 (autoload 'make-dialog-prompt-stream "gui")
 
+;; Threads
+(in-package "THREADS")
+(export 'with-thread-lock)
+(autoload-macro 'with-thread-lock)
+(export 'with-mutex)
+(autoload-macro 'with-mutex)
 
+
 ;; JVM compiler.
 (in-package "JVM")
 (export '(jvm-compile-package))
Index: src/org/armedbear/lisp/Mutex.java
===================================================================
--- src/org/armedbear/lisp/Mutex.java	(revision 12040)
+++ src/org/armedbear/lisp/Mutex.java	(working copy)
@@ -94,7 +94,6 @@
         notify();
     }
 
-
     @Override
     public String writeToString()
     {
@@ -148,4 +147,5 @@
                                             " is not a mutex."));
         }
     };
+
 }
