Finish the initialization.

@param container
@param isShutdownHookEnabled
338655
static void endInitialization(WeldContainer container, boolean isShutdownHookEnabled) {
        container.complete();
        // If needed, register one shutdown hook for all containers
        if (shutdownHook == null && isShutdownHookEnabled) {
            synchronized (LOCK) {
                if (shutdownHook == null) {
                    shutdownHook = new ShutdownHook();
                    SecurityActions.addShutdownHook(shutdownHook);
                }
            }
        }
        container.fireContainerInitializedEvent();
    }
395778
private Thread createShutdownHook(final Process process) {
        final Pipe errPipe = new Pipe(process.getErrorStream(), System.err).start("Error pipe");
        final Pipe outPipe = new Pipe(process.getInputStream(), System.out).start("Out pipe");
        final Pipe inPipe = new Pipe(process.getOutputStream(), System.in).start("In pipe");

        return new Thread(new Runnable() {

            @Override
            public void run() {
                inPipe.stop();
                outPipe.stop();
                errPipe.stop();

                try {
                    process.destroy();
                }
                // CHECKSTYLE:SKIP
                catch (Exception e) {
                    // ignore if already shutting down
                }
            }
        }, "Pax-Runner shutdown hook");
    }
245481
private static void addShutdownHook(final Logger log, final Process process, final String command) {
        Runtime.getRuntime().addShutdownHook(new Thread(command) {
            @Override
            public void run() {
                if (process != null) {
                    log.info("Terminating process [" + command + "]");
                    try {
                        process.destroy();
                    } catch (Exception e) {
                        log.error("Failed to terminate process [" + command + "]");
                    }
                }
            }
        });
    }
1305411
public synchronized void setAutoShutdownEnabled(boolean enabled) {
        try {
            if (mShutdownHook == null) {
                if (enabled) {
                    ShutdownHook hook = new ShutdownHook(this);
                    Runtime.getRuntime().addShutdownHook(hook);
                    mShutdownHook = hook;
                }
            } else {
                if (!enabled) {
                    Runtime.getRuntime().removeShutdownHook(mShutdownHook);
                    mShutdownHook = null;
                }
            }
        } catch (IllegalStateException e) {
            // Shutdown is in progress so make no changes.
        }
    }
702865
public function tearDownMockery()
    {
        if (class_exists(Mockery::class, false)) {
            $container = Mockery::getContainer();

            if ($container) {
                $this->addToAssertionCount($container->mockery_getExpectationCount());
            }

            Mockery::close();
        }
    }
92090
public void init(InputStream is, OutputStream os)
  {
    this._is = is;
    _os = os;
    //setPath(null);
    _flushOnNewline = false;
    _closeChildOnClose = true;
    _position = 0;
  }
1330046
@Override void onShutdown() {
        BlockingQueue<Runnable> q = super.getQueue();
        boolean keepDelayed =
            getExecuteExistingDelayedTasksAfterShutdownPolicy();
        boolean keepPeriodic =
            getContinueExistingPeriodicTasksAfterShutdownPolicy();
        if (!keepDelayed && !keepPeriodic) {
            for (Object e : q.toArray())
                if (e instanceof RunnableScheduledFuture<?>)
                    ((RunnableScheduledFuture<?>) e).cancel(false);
            q.clear();
        }
        else {
            // Traverse snapshot to avoid iterator exceptions
            for (Object e : q.toArray()) {
                if (e instanceof RunnableScheduledFuture) {
                    RunnableScheduledFuture<?> t =
                        (RunnableScheduledFuture<?>)e;
                    if ((t.isPeriodic() ? !keepPeriodic : !keepDelayed) ||
                        t.isCancelled()) { // also remove if already cancelled
                        if (q.remove(t))
                            t.cancel(false);
                    }
                }
            }
        }
        tryTerminate();
    }
11195
@Override
    public void onFinish(ISuite suite) {
        logger.entering(suite);
        if (ListenerManager.isCurrentMethodSkipped(this)) {
            logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG);
            return;
        }
        LocalGridManager.shutDownHub();
        logger.exiting();
    }
792109
private Thread createShutdownHook( final Process process )
    {
        LOG.debug( "Wrapping stream I/O." );

        return new Thread(
            new Runnable()
            {
                public void run()
                {
                    try
                    {
                        process.destroy();
                    }
                    catch( Exception e )
                    {
                        // ignore if already shutting down
                    }
                }
            },
            "DefaultJavaRunner shutdown hook"
        );
    }
473000
static synchronized void shutDownHub() {
        LOGGER.entering();
        if (!isRunLocally()) {
            LOGGER.exiting();
            return;
        }

        // shutdown in reverse order
        Collections.reverse(toBoot);
        for (LocalServerComponent eachItem : toBoot) {
            eachItem.shutdown();
        }
        clearToBootList();
        LOGGER.exiting();
    }
204342
static void shutdown() {
        synchronized (lock) {
            switch (state) {
            case RUNNING:       /* Initiate shutdown */
                state = HOOKS;
                break;
            case HOOKS:         /* Stall and then return */
            case FINALIZERS:
                break;
            }
        }
        synchronized (Shutdown.class) {
            sequence();
        }
    }
4686
private void finishValue()
    {
        final ContainerInfo current = currentContainer();
        if (current != null && current.type == ContainerType.ANNOTATION)
        {
            // close out and patch the length
            popContainer();
        }
        hasWrittenValuesSinceFinished = true;
        hasWrittenValuesSinceConstructed = true;
    }
1049754
public ProcessAdapter registerShutdownHook() {
    Runtime.getRuntime().addShutdownHook(
      newThread(String.format("Process [%d] Runtime Shutdown Hook", safeGetId()), this::stop));

    return this;
  }
566853
@SuppressWarnings({"deprecation", "WeakerAccess"})
  protected void removeShutdownHook(ClassLoaderLeakPreventor preventor, Thread shutdownHook) {
    final String displayString = "'" + shutdownHook + "' of type " + shutdownHook.getClass().getName();
    preventor.error("Removing shutdown hook: " + displayString);
    Runtime.getRuntime().removeShutdownHook(shutdownHook);

    if(executeShutdownHooks) { // Shutdown hooks should be executed
      
      preventor.info("Executing shutdown hook now: " + displayString);
      // Make sure it's from protected ClassLoader
      shutdownHook.start(); // Run cleanup immediately
      
      if(shutdownHookWaitMs > 0) { // Wait for shutdown hook to finish
        try {
          shutdownHook.join(shutdownHookWaitMs); // Wait for thread to run
        }
        catch (InterruptedException e) {
          // Do nothing
        }
        if(shutdownHook.isAlive()) {
          preventor.warn(shutdownHook + "still running after " + shutdownHookWaitMs + " ms - Stopping!");
          shutdownHook.stop();
        }
      }
    }
  }
1247684
public function finalize(): void
    {
        if ($this->currentAnnotation !== null) {
            if ($this->currentAnnotationContent === null) {
                $this->parsedAnnotations[] = $this->currentAnnotation;
            } else {
                throw new AnnotationParseException(
                    'An annotation content is not closed (you probably forget to close a parenthesis or a quote)'
                );
            }
        }
    }
228260
public synchronized void waitForLevel() {
        while (!levelReached) {
            if (hookSet == false) {
                Runtime.getRuntime().addShutdownHook(shutdownHook);
                hookSet = true;
            }

            try {
                wait();
            } catch (InterruptedException e) {
                /** No-op **/
            }
        }
    }
498696
public synchronized void finalReap() {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "finalReap : Remote Async Results = " + ivAllRemoteAsyncResults.size());

        // Re-write the finalReap to use the LinkedHashSet, iterating thru the list removing
        // all the entries no matter if they have timed out or not.  Cancel alarm if set.    d623593
        if (ivFuture != null) {
            ivIsCanceled = true;
            ivFuture.cancel(false);
            ivFuture = null;
        }

        for (Iterator<RemoteAsyncResultImpl> iterator = ivAllRemoteAsyncResults.iterator(); iterator.hasNext();) {
            RemoteAsyncResultImpl asyncResult = iterator.next();
            releaseResources(asyncResult); // d690014.3
            iterator.remove();
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "finalReap : Remote Async Results = " + ivAllRemoteAsyncResults.size());
    }