SynchronousExecutor.java :  » Database-JDBC-Connection-Pool » HA-JDBC » net » sf » hajdbc » util » concurrent » Java Open Source

Java Open Source » Database JDBC Connection Pool » HA JDBC 
HA JDBC » net » sf » hajdbc » util » concurrent » SynchronousExecutor.java
/*
 * HA-JDBC: High-Availability JDBC
 * Copyright (c) 2004-2007 Paul Ferraro
 * 
 * This library is free software; you can redistribute it and/or modify it 
 * under the terms of the GNU Lesser General Public License as published by the 
 * Free Software Foundation; either version 2.1 of the License, or (at your 
 * option) any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 
 * for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, 
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 * 
 * Contact: ferraro@users.sourceforge.net
 */
package net.sf.hajdbc.util.concurrent;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Executor service that executes tasks in the caller thread.
 * 
 * @author Paul Ferraro
 */
public class SynchronousExecutor extends AbstractExecutorService
{
  private boolean shutdown;
  
  /**
   * @see java.util.concurrent.ExecutorService#awaitTermination(long, java.util.concurrent.TimeUnit)
   */
  @Override
  public boolean awaitTermination(long time, TimeUnit unit)
  {
    return true;
  }

  /**
   * @see java.util.concurrent.ExecutorService#isShutdown()
   */
  @Override
  public boolean isShutdown()
  {
    return this.shutdown;
  }

  /**
   * @see java.util.concurrent.ExecutorService#isTerminated()
   */
  @Override
  public boolean isTerminated()
  {
    return this.shutdown;
  }

  /**
   * @see java.util.concurrent.ExecutorService#shutdown()
   */
  @Override
  public void shutdown()
  {
    this.shutdown = true;
  }

  /**
   * @see java.util.concurrent.ExecutorService#shutdownNow()
   */
  @Override
  public List<Runnable> shutdownNow()
  {
    this.shutdown();
    
    return Collections.emptyList();
  }

  /**
   * @see java.util.concurrent.Executor#execute(java.lang.Runnable)
   */
  @Override
  public void execute(Runnable task)
  {
    task.run();
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.