Java Doc for QueueThread.java in  » Test-Coverage » GroboUtils » net » sourceforge » groboutils » util » thread » v1 » 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 » Test Coverage » GroboUtils » net.sourceforge.groboutils.util.thread.v1 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sourceforge.groboutils.util.thread.v1.LoopThread
      net.sourceforge.groboutils.util.thread.v1.QueueThread

QueueThread
public class QueueThread extends LoopThread (Code)
For threads which endlessly process events from a SynchQueue. This is a common technique for thread pooling.

Users must make a implementation of IObjectListener. If the user does not give a SynchQueue, it is created for them. Once the QueueThread is created, the queue and the listener cannot be changed.

By default, the underlying LoopThread does not sleep between events, it is a daemon thread, runs on the lowest thread priority, and has not started yet. Of course, this can all be changed.

It is advisable not to use the methods LoopThread.setSleepTime(int) or LoopThread.setSleepTimeMillis(long) , since these will cause the QueueThread to not respond to incoming requests during this sleep time. However, there may be occations when this is necessary, so this is left available to the user.

Since the SynchQueue.dequeue method can wait indefinitely, you may opt to set the dequeue's timeout to something other than 0. Without setting this, the thread may wait indefinitely for an incoming element to the queue without ever checking for a LoopThread.stop or LoopThread.suspend signal. Thanks to Dominique Gallot for pointing this out.

After a LoopThread.stop is invoked, you may allow the object listener to finish processing the remaining elements in the inner queue by calling QueueThread.processRemaining() .
author:
   Matt Albrecht groboclown@users.sourceforge.net
since:
   June 4, 2000
version:
   $Date: 2003/02/10 22:52:48 $




Constructor Summary
public  QueueThread(IObjectListener ol)
    
public  QueueThread(IObjectListener ol, SynchQueue sq)
    
public  QueueThread(IObjectListener ol, ThreadGroup tg)
    
public  QueueThread(IObjectListener ol, SynchQueue sq, ThreadGroup tg)
    
public  QueueThread(IObjectListener ol, String threadName)
    
public  QueueThread(IObjectListener ol, SynchQueue sq, String threadName)
    
public  QueueThread(IObjectListener ol, ThreadGroup tg, String threadName)
    
public  QueueThread(IObjectListener ol, SynchQueue sq, ThreadGroup tg, String threadName)
    

Method Summary
public  SynchQueuegetQueue()
     Retrieves the internal listened queue.
public  longgetTimeoutMilliseconds()
     Retrieve the millisecond part of the maximum timeout to wait for an incoming element on the inner queue before checking for thread event signals.
public  intgetTimeoutNanoseconds()
     Retrieve the nanosecond part of the maximum timeout to wait for an incoming element on the inner queue before checking for thread event signals.
protected  voidinitialize(IObjectListener ol, SynchQueue sq)
    
protected  voidinitializeDefaults()
    
public  booleanisProcessingObjects()
    
public  voidprocessRemaining()
     Process all elements in the queue until the queue is empty.
public  voidsetTimeout(long timeout, int nanos)
     Set the maximum time (in milliseconds and nanoseconds) to wait for an incoming element on the inner queue before checking for LoopThread.stop and LoopThread.suspend signals.
public  voidsetTimeout(long timeout)
     Set the maximum time (in milliseconds) to wait for an incoming element on the inner queue before checking for LoopThread.stop and LoopThread.suspend signals.


Constructor Detail
QueueThread
public QueueThread(IObjectListener ol)(Code)



QueueThread
public QueueThread(IObjectListener ol, SynchQueue sq)(Code)



QueueThread
public QueueThread(IObjectListener ol, ThreadGroup tg)(Code)



QueueThread
public QueueThread(IObjectListener ol, SynchQueue sq, ThreadGroup tg)(Code)



QueueThread
public QueueThread(IObjectListener ol, String threadName)(Code)



QueueThread
public QueueThread(IObjectListener ol, SynchQueue sq, String threadName)(Code)



QueueThread
public QueueThread(IObjectListener ol, ThreadGroup tg, String threadName)(Code)



QueueThread
public QueueThread(IObjectListener ol, SynchQueue sq, ThreadGroup tg, String threadName)(Code)




Method Detail
getQueue
public SynchQueue getQueue()(Code)
Retrieves the internal listened queue.



getTimeoutMilliseconds
public long getTimeoutMilliseconds()(Code)
Retrieve the millisecond part of the maximum timeout to wait for an incoming element on the inner queue before checking for thread event signals.
See Also:   QueueThread.setTimeout(long,int)



getTimeoutNanoseconds
public int getTimeoutNanoseconds()(Code)
Retrieve the nanosecond part of the maximum timeout to wait for an incoming element on the inner queue before checking for thread event signals.
See Also:   QueueThread.setTimeout(long,int)



initialize
protected void initialize(IObjectListener ol, SynchQueue sq)(Code)



initializeDefaults
protected void initializeDefaults()(Code)



isProcessingObjects
public boolean isProcessingObjects()(Code)
false if the thread is waiting for an objectto be placed in the queue and be processed, otherwisetrue.



processRemaining
public void processRemaining() throws InterruptedException(Code)
Process all elements in the queue until the queue is empty. This may only be called while the thread is not running.

This should be invoked with care, as it can cause an infinite loop if another thread is pushing in data after this processing thread has finished (but, that could also lead to an out-of-memory error if this method is never invoked).




setTimeout
public void setTimeout(long timeout, int nanos)(Code)
Set the maximum time (in milliseconds and nanoseconds) to wait for an incoming element on the inner queue before checking for LoopThread.stop and LoopThread.suspend signals.
Parameters:
  timeout - the maximum time to wait in milliseconds.
Parameters:
  nanos - additional time, in nanoseconds range 0-999999.
See Also:   SynchQueue.dequeue(longint)



setTimeout
public void setTimeout(long timeout)(Code)
Set the maximum time (in milliseconds) to wait for an incoming element on the inner queue before checking for LoopThread.stop and LoopThread.suspend signals.
Parameters:
  timeout - the maximum time to wait in milliseconds.
Parameters:
  nanos - additional time, in nanoseconds range 0-999999.
See Also:   SynchQueue.dequeue(longint)
See Also:   QueueThread.setTimeout(long,int)



Fields inherited from net.sourceforge.groboutils.util.thread.v1.LoopThread
final public static long MILLI_IN_SECOND(Code)(Java Doc)

Methods inherited from net.sourceforge.groboutils.util.thread.v1.LoopThread
public int getPriority()(Code)(Java Doc)
public int getSleepTime()(Code)(Java Doc)
public long getSleepTimeMillis()(Code)(Java Doc)
public ThreadGroup getThreadGroup()(Code)(Java Doc)
public boolean isAlive()(Code)(Java Doc)
public boolean isDaemon()(Code)(Java Doc)
public boolean isPaused()(Code)(Java Doc)
public boolean isRunning()(Code)(Java Doc)
public void join() throws InterruptedException(Code)(Java Doc)
public void resume()(Code)(Java Doc)
public void setDaemon(boolean on)(Code)(Java Doc)
public void setPriority(int priority)(Code)(Java Doc)
public void setRunnable(Runnable run)(Code)(Java Doc)
public void setSleepTime(int seconds)(Code)(Java Doc)
public void setSleepTimeMillis(long millis)(Code)(Java Doc)
public void start()(Code)(Java Doc)
public void stop()(Code)(Java Doc)
public void suspend()(Code)(Java Doc)
public String toString()(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

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