Native threads almost working
[cacao.git] / main.c
diff --git a/main.c b/main.c
index b1f3ad3ab18cf20135545fd4678563f7c57e9378..1f087e868844c255f207cdbf995a3433de16f316 100644 (file)
--- a/main.c
+++ b/main.c
@@ -37,7 +37,7 @@
      - Calling the class loader
      - Running the main method
 
-   $Id: main.c 964 2004-03-15 14:52:43Z jowenn $
+   $Id: main.c 991 2004-03-29 11:22:34Z stefan $
 
 */
 
@@ -873,19 +873,29 @@ int main(int argc, char **argv)
                log_text("CACAO started -------------------------------------------------------");
        }
 
+       heap_init(heapsize, heapstartsize, &dummy);
+
        native_setclasspath(classpath);
                
        tables_init();
        suck_init(classpath);
 
-       heap_init(heapsize, heapstartsize, &dummy);
-
        jit_init();
 
+#if defined(USE_THREADS) && defined(NATIVE_THREADS)
+       initThreadsEarly();
+#endif
+
        loader_init((u1 *) &dummy);
 
        native_loadclasses();
 
+       /* initialize the garbage collector */
+       gc_init();
+
+#if defined(USE_THREADS)
+       initThreads((u1*) &dummy);
+#endif
 
        /*********************** Load JAVA classes  ***************************/
    
@@ -908,14 +918,6 @@ int main(int argc, char **argv)
                exit(1);
        }
 
-       /* initialize the garbage collector */
-       gc_init();
-
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
-       initThreads((u1*) &dummy);
-#endif
-
-
        /************************* Start worker routines ********************/
 
        if (startit) {
@@ -972,10 +974,13 @@ int main(int argc, char **argv)
                        }
                }
 
-#if defined(USE_THREADS) && !defined(NATIVE_THREADS)
+#if defined(USE_THREADS)
+#if defined(NATIVE_THREADS)
+               joinAllThreads();
+#else
                killThread(currentThread);
                fprintf(stderr, "still here\n");
-
+#endif
 #endif
                exit(0);
        }