<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FThreads%2FCountDownLatch</id>
		<title>Java/Threads/CountDownLatch - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FThreads%2FCountDownLatch"/>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Threads/CountDownLatch&amp;action=history"/>
		<updated>2026-04-24T18:46:53Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Threads/CountDownLatch&amp;diff=8291&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Threads/CountDownLatch&amp;diff=8291&amp;oldid=prev"/>
				<updated>2010-06-01T06:58:24Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:58, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://www.jexp.ru/index.php?title=Java/Threads/CountDownLatch&amp;diff=8290&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.jexp.ru/index.php?title=Java/Threads/CountDownLatch&amp;diff=8290&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:46Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== An example of CountDownLatch. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
  &lt;br /&gt;
   &lt;br /&gt;
import java.util.concurrent.CountDownLatch;&lt;br /&gt;
   &lt;br /&gt;
public class CDLDemo {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    CountDownLatch cdl = new CountDownLatch(5);&lt;br /&gt;
    new MyThread(cdl);&lt;br /&gt;
   &lt;br /&gt;
    try {&lt;br /&gt;
      cdl.await();&lt;br /&gt;
    } catch (InterruptedException exc) {&lt;br /&gt;
      System.out.println(exc);&lt;br /&gt;
    }&lt;br /&gt;
    System.out.println(&amp;quot;Done&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
class MyThread implements Runnable {&lt;br /&gt;
  CountDownLatch latch;&lt;br /&gt;
   &lt;br /&gt;
  MyThread(CountDownLatch c) {&lt;br /&gt;
    latch = c;&lt;br /&gt;
    new Thread(this).start();&lt;br /&gt;
  }&lt;br /&gt;
   &lt;br /&gt;
  public void run() {&lt;br /&gt;
    for(int i = 0; i&amp;lt;5; i++) {&lt;br /&gt;
      System.out.println(i);&lt;br /&gt;
      latch.countDown(); // decrement count&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Count Up Down Latch ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
/* Copyright (c) 2001-2009, The HSQL Development Group&lt;br /&gt;
 * All rights reserved.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistribution and use in source and binary forms, with or without&lt;br /&gt;
 * modification, are permitted provided that the following conditions are met:&lt;br /&gt;
 *&lt;br /&gt;
 * Redistributions of source code must retain the above copyright notice, this&lt;br /&gt;
 * list of conditions and the following disclaimer.&lt;br /&gt;
 *&lt;br /&gt;
 * Redistributions in binary form must reproduce the above copyright notice,&lt;br /&gt;
 * this list of conditions and the following disclaimer in the documentation&lt;br /&gt;
 * and/or other materials provided with the distribution.&lt;br /&gt;
 *&lt;br /&gt;
 * Neither the name of the HSQL Development Group nor the names of its&lt;br /&gt;
 * contributors may be used to endorse or promote products derived from this&lt;br /&gt;
 * software without specific prior written permission.&lt;br /&gt;
 *&lt;br /&gt;
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot;&lt;br /&gt;
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE&lt;br /&gt;
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE&lt;br /&gt;
 * ARE DISCLAIMED. IN NO EVENT SHALL HSQL DEVELOPMENT GROUP, HSQLDB.ORG,&lt;br /&gt;
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,&lt;br /&gt;
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,&lt;br /&gt;
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;&lt;br /&gt;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND&lt;br /&gt;
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT&lt;br /&gt;
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS&lt;br /&gt;
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
import java.util.concurrent.CountDownLatch;&lt;br /&gt;
public class CountUpDownLatch {&lt;br /&gt;
    CountDownLatch latch;&lt;br /&gt;
    int            count;&lt;br /&gt;
    public CountUpDownLatch() {&lt;br /&gt;
        latch      = new CountDownLatch(1);&lt;br /&gt;
        this.count = count;&lt;br /&gt;
    }&lt;br /&gt;
    public void await() throws InterruptedException {&lt;br /&gt;
        if (count == 0) {&lt;br /&gt;
            return;&lt;br /&gt;
        }&lt;br /&gt;
        latch.await();&lt;br /&gt;
    }&lt;br /&gt;
    public void countDown() {&lt;br /&gt;
        count--;&lt;br /&gt;
        if (count == 0) {&lt;br /&gt;
            latch.countDown();&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public long getCount() {&lt;br /&gt;
        return count;&lt;br /&gt;
    }&lt;br /&gt;
    public void countUp() {&lt;br /&gt;
        if (latch.getCount() == 0) {&lt;br /&gt;
            latch = new CountDownLatch(1);&lt;br /&gt;
        }&lt;br /&gt;
        count++;&lt;br /&gt;
    }&lt;br /&gt;
    public void setCount(int count) {&lt;br /&gt;
        if (count == 0) {&lt;br /&gt;
            if (latch.getCount() != 0) {&lt;br /&gt;
                latch.countDown();&lt;br /&gt;
            }&lt;br /&gt;
        } else if (latch.getCount() == 0) {&lt;br /&gt;
            latch = new CountDownLatch(1);&lt;br /&gt;
        }&lt;br /&gt;
        this.count = count;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>