src/main/java/toy/servers/ToyBaseServer_old.java
/**
     * shutdown the server as either part of Toys (e.g as with Top) or a single server
     * @param group indicates if this server is part of group of Toys that collaborate
     *              wrb, panic and sync services
     */
shutdown the server as either part of Toys  or a single server
@param group indicates if this server is part of group of Toys that collaborate
wrb, panic and sync services
shutdown the server as either part of Toys or a single server @param group indicates if this server is part of group of Toys that collaborate wrb panic and sync services
public void shutdown(boolean group) {
        stopped.set(true);
        logger.debug(format("[#%d-C[%d]] interrupt main thread", getID(), channel));
        AtomicBoolean j = new AtomicBoolean(false);
        Thread t = new Thread(() -> {
            while (!j.get()) {
                mainThread.interrupt();
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    logger.error("", e);
                }
            }
        });
        t.start();
        try {
            mainThread.join();
            j.set(true);
            t.join();
        } catch (InterruptedException e) {
            logger.error(format("[#%d-C[%d]]", getID(), channel), e);
        }
        if (!group) {
            if (wrbServer != null) wrbServer.stop();
            if (panicRB != null) panicRB.shutdown();
            if (syncRB != null) syncRB.shutdown();
        }
        logger.debug(format("[#%d-C[%d]] interrupt panic thread", getID(), channel));
        j.set(false);
        t = new Thread(() -> {
            while (!j.get()) {
                panicThread.interrupt();
                try {
                    Thread.sleep( 1000);
                } catch (InterruptedException e) {
                    logger.error("", e);
                }
            }
        });
        t.start();
        try {
            panicThread.join();
            j.set(true);
            t.join();
        } catch (InterruptedException e) {
            logger.error(format("[#%d-C[%d]]", getID(), channel), e);
        }
        logger.info(format("[#%d-C[%d]] shutdown bc Server", getID(), channel));
    }
public void shutdown ( boolean group ) { stopped . set ( true ) ; logger . debug ( format ( "[#%d-C[%d]] interrupt main thread" , getID ( ) , channel ) ) ; AtomicBoolean j = new AtomicBoolean ( false ) ; Thread t = new Thread ( ( ) -> { while ( ! j . get ( ) ) { mainThread . interrupt ( ) ; try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { logger . error ( "" , e ) ; } } } ) ; t . start ( ) ; try { mainThread . join ( ) ; j . set ( true ) ; t . join ( ) ; } catch ( InterruptedException e ) { logger . error ( format ( "[#%d-C[%d]]" , getID ( ) , channel ) , e ) ; } if ( ! group ) { if ( wrbServer != null ) wrbServer . stop ( ) ; if ( panicRB != null ) panicRB . shutdown ( ) ; if ( syncRB != null ) syncRB . shutdown ( ) ; } logger . debug ( format ( "[#%d-C[%d]] interrupt panic thread" , getID ( ) , channel ) ) ; j . set ( false ) ; t = new Thread ( ( ) -> { while ( ! j . get ( ) ) { panicThread . interrupt ( ) ; try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { logger . error ( "" , e ) ; } } } ) ; t . start ( ) ; try { panicThread . join ( ) ; j . set ( true ) ; t . join ( ) ; } catch ( InterruptedException e ) { logger . error ( format ( "[#%d-C[%d]]" , getID ( ) , channel ) , e ) ; } logger . info ( format ( "[#%d-C[%d]] shutdown bc Server" , getID ( ) , channel ) ) ; }
shutdown the server as either part of Toys (e.g as with Top) or a single server
 @param group indicates if this server is part of group of Toys that collaborate
              wrb, panic and sync services
shutdown the server as either part of Toys ( e . g as with Top ) or a single server @param group indicates if this server is part of group of Toys that collaborate wrb panic and sync services