Source Code Cross Referenced for CompletionService.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » concurrent » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util.concurrent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
003         *
004         * This code is free software; you can redistribute it and/or modify it
005         * under the terms of the GNU General Public License version 2 only, as
006         * published by the Free Software Foundation.  Sun designates this
007         * particular file as subject to the "Classpath" exception as provided
008         * by Sun in the LICENSE file that accompanied this code.
009         *
010         * This code is distributed in the hope that it will be useful, but WITHOUT
011         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
013         * version 2 for more details (a copy is included in the LICENSE file that
014         * accompanied this code).
015         *
016         * You should have received a copy of the GNU General Public License version
017         * 2 along with this work; if not, write to the Free Software Foundation,
018         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
019         *
020         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
021         * CA 95054 USA or visit www.sun.com if you need additional information or
022         * have any questions.
023         */
024
025        /*
026         * This file is available under and governed by the GNU General Public
027         * License version 2 only, as published by the Free Software Foundation.
028         * However, the following notice accompanied the original version of this
029         * file:
030         *
031         * Written by Doug Lea with assistance from members of JCP JSR-166
032         * Expert Group and released to the public domain, as explained at
033         * http://creativecommons.org/licenses/publicdomain
034         */
035
036        package java.util.concurrent;
037
038        /**
039         * A service that decouples the production of new asynchronous tasks
040         * from the consumption of the results of completed tasks.  Producers
041         * <tt>submit</tt> tasks for execution. Consumers <tt>take</tt>
042         * completed tasks and process their results in the order they
043         * complete.  A <tt>CompletionService</tt> can for example be used to
044         * manage asynchronous IO, in which tasks that perform reads are
045         * submitted in one part of a program or system, and then acted upon
046         * in a different part of the program when the reads complete,
047         * possibly in a different order than they were requested.
048         *
049         * <p>Typically, a <tt>CompletionService</tt> relies on a separate
050         * {@link Executor} to actually execute the tasks, in which case the
051         * <tt>CompletionService</tt> only manages an internal completion
052         * queue. The {@link ExecutorCompletionService} class provides an
053         * implementation of this approach.
054         *
055         * <p>Memory consistency effects: Actions in a thread prior to
056         * submitting a task to a {@code CompletionService}
057         * <a href="package-summary.html#MemoryVisibility"><i>happen-before</i></a>
058         * actions taken by that task, which in turn <i>happen-before</i>
059         * actions following a successful return from the corresponding {@code take()}.
060         *
061         */
062        public interface CompletionService<V> {
063            /**
064             * Submits a value-returning task for execution and returns a Future
065             * representing the pending results of the task.  Upon completion,
066             * this task may be taken or polled.
067             *
068             * @param task the task to submit
069             * @return a Future representing pending completion of the task
070             * @throws RejectedExecutionException if the task cannot be
071             *         scheduled for execution
072             * @throws NullPointerException if the task is null
073             */
074            Future<V> submit(Callable<V> task);
075
076            /**
077             * Submits a Runnable task for execution and returns a Future
078             * representing that task.  Upon completion, this task may be
079             * taken or polled.
080             *
081             * @param task the task to submit
082             * @param result the result to return upon successful completion
083             * @return a Future representing pending completion of the task,
084             *         and whose <tt>get()</tt> method will return the given
085             *         result value upon completion
086             * @throws RejectedExecutionException if the task cannot be
087             *         scheduled for execution
088             * @throws NullPointerException if the task is null
089             */
090            Future<V> submit(Runnable task, V result);
091
092            /**
093             * Retrieves and removes the Future representing the next
094             * completed task, waiting if none are yet present.
095             *
096             * @return the Future representing the next completed task
097             * @throws InterruptedException if interrupted while waiting
098             */
099            Future<V> take() throws InterruptedException;
100
101            /**
102             * Retrieves and removes the Future representing the next
103             * completed task or <tt>null</tt> if none are present.
104             *
105             * @return the Future representing the next completed task, or
106             *         <tt>null</tt> if none are present
107             */
108            Future<V> poll();
109
110            /**
111             * Retrieves and removes the Future representing the next
112             * completed task, waiting if necessary up to the specified wait
113             * time if none are yet present.
114             *
115             * @param timeout how long to wait before giving up, in units of
116             *        <tt>unit</tt>
117             * @param unit a <tt>TimeUnit</tt> determining how to interpret the
118             *        <tt>timeout</tt> parameter
119             * @return the Future representing the next completed task or
120             *         <tt>null</tt> if the specified waiting time elapses
121             *         before one is present
122             * @throws InterruptedException if interrupted while waiting
123             */
124            Future<V> poll(long timeout, TimeUnit unit)
125                    throws InterruptedException;
126        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.