/*
 * Copyright 2010-2011 Roger Kapsi
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package org.ardverk.concurrent;

import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * A simple {@link CountDown}.
 */
public class CountDown implements Serializable {
    
    private static final long serialVersionUID = 2884657259566757243L;

    private final int value;
    
    private final AtomicInteger countdown;
    
    public CountDown(int value) {
        if (value < 0) {
            throw new IllegalArgumentException("value=" + value);
        }
        
        this.value = value;
        this.countdown = new AtomicInteger(value);
    }
    
    /**
     * Returns the {@link CountDown}'s initial value.
     */
    public int getInitialValue() {
        return value;
    }
    
    /**
     * Returns the {@link CountDown}'s current value.
     */
    public int getCurrentValue() {
        return countdown.get();
    }
    
    /**
     * Decrements the {@link CountDown} by 1 and returns {@code true}
     * if the {@link CountDown} has reached zero or less.
     */
    public boolean countDown() {
        return countdown.decrementAndGet() <= 0;
    }
}

@@ -649,37 +649,8 @@
 t;%0A%0A
-import java.io.Serializable;%0A
 impo
@@ -762,31 +762,29 @@
 own 
-implements Serializable
+extends AtomicInteger
  %7B%0A 
@@ -840,436 +840,94 @@
 D = 
-2884657259566757243L;%0A%0A    private final int value;%0A    %0A    private final AtomicInteger countdown;%0A    %0A    public CountDown(int value) %7B%0A        if (value %3C 0) %7B%0A            throw new IllegalArgumentException(%22value=%22 + value);%0A        %7D%0A  
+-4789846820544350132L;%0A%0A    public CountDown() %7B%0A    %7D%0A
     
-  
 %0A    
-    this.value = value;%0A        this.countdown = new AtomicInteger(value);%0A    %7D%0A    %0A    /**%0A     * Returns the %7B@link CountDown%7D's initial value.%0A     */%0A    public int getI
+public CountDown(int i
 niti
@@ -929,25 +929,24 @@
 initialValue
-(
 ) %7B%0A        
@@ -949,167 +949,26 @@
     
-return value;%0A    %7D%0A    %0A    /**%0A     * Returns the %7B@link CountDown%7D's current value.%0A     */%0A    public int getCurrentValue() %7B%0A        return countdown.get(
+super(initialValue
 );%0A 
@@ -1107,16 +1107,8 @@
 zero
- or less
 .%0A  
@@ -1165,18 +1165,8 @@
 urn 
-countdown.
 decr
@@ -1183,9 +1183,9 @@
 t() 
-%3C
+=
 = 0;

Extend from AtomicInteger