NS_InitXPCOM2(nsnull, nsnull, nsnull); nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL );
nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); registrar->AutoRegister(nsnull);
main(int argc, char **argv){    int numberOfThreads = 1;    if (argc > 1)        numberOfThreads = atoi(argv[1]);    NS_InitXPCOM2(nsnull, nsnull, nsnull);    nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,                                     NULL /* default */);    static PRThread** threads = (PRThread**) calloc(sizeof(PRThread*), numberOfThreads);    static PRThread*  aEventThread;        aEventThread =   PR_CreateThread(PR_USER_THREAD,                                     EventLoop,                                     NULL,                                     PR_PRIORITY_NORMAL,                                     PR_GLOBAL_THREAD,                                     PR_JOINABLE_THREAD,                                     0 );        PR_Sleep(PR_MillisecondsToInterval(1000));    NS_ASSERTION(gEventQueue, "no main event queue"); // BAD BAD BAD.  EVENT THREAD DID NOT CREATE QUEUE.  This may be a timing issue, set the                             // sleep about longer, and try again.    printf("Spawn Threads:\n");    for (PRInt32 spawn = 0; spawn < numberOfThreads; spawn++)    {        ArgsStruct *args = (ArgsStruct *) malloc (sizeof(ArgsStruct));                args->queue = gEventQueue;        NS_ADDREF(args->queue);        args->threadNumber = spawn;        threads[spawn]  =   PR_CreateThread(PR_USER_THREAD,                                            ProxyTest,                                            args,                                            PR_PRIORITY_NORMAL,                                            PR_GLOBAL_THREAD,                                            PR_JOINABLE_THREAD,                                            0 );        printf("\tThread (%d) spawned\n", spawn);        PR_Sleep( PR_MillisecondsToInterval(250) );    }    printf("All Threads Spawned.\n\n");              printf("Wait for threads.\n");    for (PRInt32 i = 0; i < numberOfThreads; i++)    {        PRStatus rv;        printf("Thread (%d) Join...\n", i);        rv = PR_JoinThread(threads[i]);        printf("Thread (%d) Joined. (error: %d).\n", i, rv);    }    PR_Interrupt(aEventThread);    PR_JoinThread(aEventThread);        printf("Calling Cleanup.\n");    PR_Cleanup();    printf("Return zero.\n");    return 0;}