Code example for Writer

Methods: close, write

0
            if (mLooperThread.isAlive()) {
                fail("Failed to stop the looper.");
            } 
            mLooperThread = null;
        } 
        mOutput.write("\n\n");
        mOutput.close();
        super.tearDown(); 
    } 
 
    private void runOnLooper(final Runnable command) throws InterruptedException {
        final Semaphore sem = new Semaphore(0);
        mHandler.post(new Runnable() {
            @Override 
            public void run() { 
                try { 
                    command.run();
                } finally { 
                    sem.release();
                } 
            }