1 /** 2 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software 14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 * 16 */ 17 18 package org.gudy.azureus2.core3.util; 19 20 /** 21 * @author TuxPaper 22 * @created Mar 21, 2007 23 * 24 */ 25 public abstract class AERunnableBoolean 26 implements Runnable 27 { 28 private Boolean[] returnValueObject; 29 30 private AESemaphore sem; 31 32 private String id = "AEReturningRunnable"; 33 run()34 public void run() { 35 try { 36 //System.out.println(this + "]" + id + " run start"); 37 boolean b = runSupport(); 38 //System.out.println(this + "]" + id + " runSupport Done: ret=" + b); 39 if (returnValueObject != null && returnValueObject.length > 0) { 40 returnValueObject[0] = b; 41 } 42 } catch (Throwable e) { 43 Debug.out(id, e); 44 } finally { 45 //System.out.println(this + "]" + id + " sem=" + sem); 46 if (sem != null) { 47 //System.out.println(this + "]" + id + " sem Release"); 48 sem.releaseForever(); 49 } 50 } 51 } 52 setupReturn(String ID, Boolean[] returnValueObject, AESemaphore sem)53 public void setupReturn(String ID, Boolean[] returnValueObject, 54 AESemaphore sem) { 55 id = ID; 56 this.returnValueObject = returnValueObject; 57 this.sem = sem; 58 } 59 runSupport()60 public abstract boolean runSupport(); 61 } 62