Java Doc for SynchronousQueue.java in  » Apache-Harmony-Java-SE » java-package » java » util » concurrent » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » java package » java.util.concurrent 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.util.concurrent.SynchronousQueue

SynchronousQueue
public class SynchronousQueue extends AbstractQueue implements BlockingQueue<E>,java.io.Serializable(Code)
A in which each put must wait for a take, and vice versa. A synchronous queue does not have any internal capacity, not even a capacity of one. You cannot peek at a synchronous queue because an element is only present when you try to take it; you cannot add an element (using any method) unless another thread is trying to remove it; you cannot iterate as there is nothing to iterate. The head of the queue is the element that the first queued thread is trying to add to the queue; if there are no queued threads then no element is being added and the head is null. For purposes of other Collection methods (for example contains), a SynchronousQueue acts as an empty collection. This queue does not permit null elements.

Synchronous queues are similar to rendezvous channels used in CSP and Ada. They are well suited for handoff designs, in which an object running in one thread must sync up with an object running in another thread in order to hand it some information, event, or task.

This class supports an optional fairness policy for ordering waiting producer and consumer threads. By default, this ordering is not guaranteed. However, a queue constructed with fairness set to true grants threads access in FIFO order. Fairness generally decreases throughput but reduces variability and avoids starvation.

This class implements all of the optional methods of the Collection and Iterator interfaces.

This class is a member of the Java Collections Framework.
since:
   1.5
author:
   Doug Lea<
Parameters:
  E - > the type of elements held in this collection


Inner Class :abstract static class WaitQueue implements java.io.Serializable
Inner Class :final static class FifoWaitQueue extends WaitQueue implements java.io.Serializable
Inner Class :final static class LifoWaitQueue extends WaitQueue implements java.io.Serializable
Inner Class :final static class Node extends AbstractQueuedSynchronizer
Inner Class :static class EmptyIterator implements Iterator<E>


Constructor Summary
public  SynchronousQueue()
     Creates a SynchronousQueue with nonfair access policy.
public  SynchronousQueue(boolean fair)
     Creates a SynchronousQueue with specified fairness policy.

Method Summary
public  voidclear()
     Does nothing.
public  booleancontains(Object o)
     Always returns false.
public  booleancontainsAll(Collection c)
     Returns false unless given collection is empty.
public  intdrainTo(Collection<? super E> c)
    
public  intdrainTo(Collection<? super E> c, int maxElements)
    
public  booleanisEmpty()
     Always returns true.
public  Iterator<E>iterator()
     Returns an empty iterator in which hasNext always returns false.
public  booleanoffer(E o, long timeout, TimeUnit unit)
     Inserts the specified element into this queue, waiting if necessary up to the specified wait time for another thread to receive it.
public  booleanoffer(E o)
     Inserts the specified element into this queue, if another thread is waiting to receive it.
Parameters:
  o - the element to add.
public  Epeek()
     Always returns null.
public  Epoll(long timeout, TimeUnit unit)
     Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it.
public  Epoll()
     Retrieves and removes the head of this queue, if another thread is currently making an element available.
public  voidput(E o)
     Adds the specified element to this queue, waiting if necessary for another thread to receive it.
public  intremainingCapacity()
     Always returns zero.
public  booleanremove(Object o)
     Always returns false.
public  booleanremoveAll(Collection c)
     Always returns false.
public  booleanretainAll(Collection c)
     Always returns false.
public  intsize()
     Always returns zero.
public  Etake()
     Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it.
throws:
  InterruptedException - if interrupted while waiting.
public  Object[]toArray()
     Returns a zero-length array.
public  T[]toArray(T[] a)
     Sets the zeroeth element of the specified array to null (if the array has non-zero length) and returns it.


Constructor Detail
SynchronousQueue
public SynchronousQueue()(Code)
Creates a SynchronousQueue with nonfair access policy.



SynchronousQueue
public SynchronousQueue(boolean fair)(Code)
Creates a SynchronousQueue with specified fairness policy.
Parameters:
  fair - if true, threads contend in FIFO order for access;otherwise the order is unspecified.




Method Detail
clear
public void clear()(Code)
Does nothing. A SynchronousQueue has no internal capacity.



contains
public boolean contains(Object o)(Code)
Always returns false. A SynchronousQueue has no internal capacity.
Parameters:
  o - the element false



containsAll
public boolean containsAll(Collection c)(Code)
Returns false unless given collection is empty. A SynchronousQueue has no internal capacity.
Parameters:
  c - the collection false unless given collection is empty



drainTo
public int drainTo(Collection<? super E> c)(Code)



drainTo
public int drainTo(Collection<? super E> c, int maxElements)(Code)



isEmpty
public boolean isEmpty()(Code)
Always returns true. A SynchronousQueue has no internal capacity. true



iterator
public Iterator<E> iterator()(Code)
Returns an empty iterator in which hasNext always returns false. an empty iterator



offer
public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException(Code)
Inserts the specified element into this queue, waiting if necessary up to the specified wait time for another thread to receive it.
Parameters:
  o - the element to add
Parameters:
  timeout - how long to wait before giving up, in units ofunit
Parameters:
  unit - a TimeUnit determining how to interpret thetimeout parameter true if successful, or false ifthe specified waiting time elapses before a consumer appears.
throws:
  InterruptedException - if interrupted while waiting.
throws:
  NullPointerException - if the specified element is null.



offer
public boolean offer(E o)(Code)
Inserts the specified element into this queue, if another thread is waiting to receive it.
Parameters:
  o - the element to add. true if it was possible to add the element tothis queue, else false
throws:
  NullPointerException - if the specified element is null



peek
public E peek()(Code)
Always returns null. A SynchronousQueue does not return elements unless actively waited on. null



poll
public E poll(long timeout, TimeUnit unit) throws InterruptedException(Code)
Retrieves and removes the head of this queue, waiting if necessary up to the specified wait time, for another thread to insert it.
Parameters:
  timeout - how long to wait before giving up, in units ofunit
Parameters:
  unit - a TimeUnit determining how to interpret thetimeout parameter the head of this queue, or null if thespecified waiting time elapses before an element is present.
throws:
  InterruptedException - if interrupted while waiting.



poll
public E poll()(Code)
Retrieves and removes the head of this queue, if another thread is currently making an element available. the head of this queue, or null if noelement is available.



put
public void put(E o) throws InterruptedException(Code)
Adds the specified element to this queue, waiting if necessary for another thread to receive it.
Parameters:
  o - the element to add
throws:
  InterruptedException - if interrupted while waiting.
throws:
  NullPointerException - if the specified element is null.



remainingCapacity
public int remainingCapacity()(Code)
Always returns zero. A SynchronousQueue has no internal capacity. zero.



remove
public boolean remove(Object o)(Code)
Always returns false. A SynchronousQueue has no internal capacity.
Parameters:
  o - the element to remove false



removeAll
public boolean removeAll(Collection c)(Code)
Always returns false. A SynchronousQueue has no internal capacity.
Parameters:
  c - the collection false



retainAll
public boolean retainAll(Collection c)(Code)
Always returns false. A SynchronousQueue has no internal capacity.
Parameters:
  c - the collection false



size
public int size()(Code)
Always returns zero. A SynchronousQueue has no internal capacity. zero.



take
public E take() throws InterruptedException(Code)
Retrieves and removes the head of this queue, waiting if necessary for another thread to insert it.
throws:
  InterruptedException - if interrupted while waiting. the head of this queue



toArray
public Object[] toArray()(Code)
Returns a zero-length array. a zero-length array



toArray
public T[] toArray(T[] a)(Code)
Sets the zeroeth element of the specified array to null (if the array has non-zero length) and returns it.
Parameters:
  a - the array the specified array



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.