Java Doc for RunnableQueue.java in  » 6.0-JDK-Modules » j2me » com » sun » perseus » util » 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 » 6.0 JDK Modules » j2me » com.sun.perseus.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.sun.perseus.util.RunnableQueue

RunnableQueue
final public class RunnableQueue implements Runnable(Code)
This class represents an object which queues Runnable objects for invocation in a single thread. This class is derived from work done in the Batik project but was seriously modified and extended.
version:
   $Id: RunnableQueue.java,v 1.5 2006/04/21 06:35:50 st125089 Exp $

Inner Class :public interface RunnableHandler
Inner Class :public interface RunnableQueueHandler
Inner Class :public static class VoidQueueHandler implements RunnableQueueHandler
Inner Class :protected static class Link extends DoublyLinkedList.Node
Inner Class :protected static class LockableLink extends Link

Field Summary
final public static  StringRUNNING
     The queue is in the processes of running tasks.
final public static  StringSUSPENDED
     The queue is no longer running any tasks and will not run any tasks until resumeExecution is called.
final public static  StringSUSPENDING
     The queue may still be running tasks but as soon as possible will go to SUSPENDED state.
final public static  StringTERMINATED
    
protected static  RunnableQueuedefaultQueue
     The default RunnableQueue instance.
protected  DoublyLinkedListlist
     The Runnable objects list, also used as synchoronization point for pushing/poping runables.
protected  RunnableQueueHandlerqueueHandler
     The object which handles RunnableQueue events.
protected  ThreadrunnableQueueThread
     The current thread.
protected  Schedulerscheduler
     The Scheduler which can run Runnables at a fixed rate.
protected  Stringstate
     The Suspension state of this thread.
protected  ObjectstateLock
     Object to synchronize/wait/notify for suspension issues.


Method Summary
public static  RunnableQueuecreateRunnableQueue(RunnableQueueHandler queueHandler)
     Creates a new RunnableQueue started in a new thread.
Parameters:
  queueHandler - the RunnableQueueHandler which will be notifiedof the RunnableQueue's activity.
public  voidempty()
     Removes all pending Runnables.
public static  RunnableQueuegetDefault()
     Returns the default RunnableQueue instance.
public  RunnablegetNextPending()
    
public  StringgetQueueState()
    
public  intgetSize()
    
public  ThreadgetThread()
     Returns the thread in which the RunnableQueue is currently running.
public  voidinvokeAndWait(Runnable r, RunnableHandler runHandler)
     Waits until the given Runnable's run() has returned.
public  voidinvokeLater(Runnable r, RunnableHandler runHandler)
     Schedules the given Runnable object for a later invocation, and returns.
public  voidpreemptAndWait(Runnable r, RunnableHandler runHandler)
     Waits until the given Runnable's run() has returned.
public  voidpreemptLater(Runnable r, RunnableHandler runHandler)
     Schedules the given Runnable object for a later invocation, and returns.
public  voidresumeExecution()
     Resumes the execution of this queue.
public  voidrun()
     Runs this queue.
public  voidsafeInvokeAndWait(Runnable r, RunnableHandler runHandler)
     Waits until the given Runnable's run() has returned. Note: safeInvokeAndWait() may be called from any thread. This method checks if this thread is the update thread, in which case the Runnable is invoked directly.
public  voidscheduleAtFixedRate(Runnable r, RunnableHandler runHandler, long interval)
     Schedules the input Runnable at the requested fixed rate.
public  voidsuspendExecution(boolean waitTillSuspended)
     Suspends the execution of this queue after the current runnable completes.
Parameters:
  waitTillSuspended - if true this method will not returnuntil the queue has suspended (no runnable in progressor about to be in progress).
public  voidunschedule(Runnable r)
     Removes the input Runnable from the list of Runnables scheduled at a fixed rate.

Field Detail
RUNNING
final public static String RUNNING(Code)
The queue is in the processes of running tasks.



SUSPENDED
final public static String SUSPENDED(Code)
The queue is no longer running any tasks and will not run any tasks until resumeExecution is called.



SUSPENDING
final public static String SUSPENDING(Code)
The queue may still be running tasks but as soon as possible will go to SUSPENDED state.



TERMINATED
final public static String TERMINATED(Code)
This queue has been interrupted



defaultQueue
protected static RunnableQueue defaultQueue(Code)
The default RunnableQueue instance.



list
protected DoublyLinkedList list(Code)
The Runnable objects list, also used as synchoronization point for pushing/poping runables.



queueHandler
protected RunnableQueueHandler queueHandler(Code)
The object which handles RunnableQueue events.



runnableQueueThread
protected Thread runnableQueueThread(Code)
The current thread.



scheduler
protected Scheduler scheduler(Code)
The Scheduler which can run Runnables at a fixed rate.



state
protected String state(Code)
The Suspension state of this thread.



stateLock
protected Object stateLock(Code)
Object to synchronize/wait/notify for suspension issues.





Method Detail
createRunnableQueue
public static RunnableQueue createRunnableQueue(RunnableQueueHandler queueHandler)(Code)
Creates a new RunnableQueue started in a new thread.
Parameters:
  queueHandler - the RunnableQueueHandler which will be notifiedof the RunnableQueue's activity. May be null. a RunnableQueue which is garanteed to have entered itsrun() method.



empty
public void empty()(Code)
Removes all pending Runnables.



getDefault
public static RunnableQueue getDefault()(Code)
Returns the default RunnableQueue instance. This is what should be used in most circumstances. In particular, all document instances which need to process in a seperate thread should share this default RunnableQueue. the default RunnableQueue instance.



getNextPending
public Runnable getNextPending()(Code)
the next pending runnable



getQueueState
public String getQueueState()(Code)
this queue's state, one of RUNNING, SUSPENDING,SUSPENDED or TERMINATED



getSize
public int getSize()(Code)
the number of pending runnables



getThread
public Thread getThread()(Code)
Returns the thread in which the RunnableQueue is currently running. null if the RunnableQueue has not entered hisrun() method.



invokeAndWait
public void invokeAndWait(Runnable r, RunnableHandler runHandler) throws InterruptedException(Code)
Waits until the given Runnable's run() has returned. Note: invokeAndWait() must not be called from the current thread (for example from the run() method of the argument).
Parameters:
  r - the Runnable to put at the end of the execution list.
Parameters:
  runHandler - the RunnableHandler to notify once the Runnable has finished executing.Should not be null.
throws:
  IllegalStateException - if getThread() is null or if thethread returned by getThread() is the current one.
throws:
  InterruptedException - if the thread is interrupted while waiting for the input Runnable to completeits execution.



invokeLater
public void invokeLater(Runnable r, RunnableHandler runHandler)(Code)
Schedules the given Runnable object for a later invocation, and returns. An exception is thrown if the RunnableQueue was not started.
Parameters:
  r - the Runnable to put at the end of theexecution list.
Parameters:
  runHandler - the RunnableHandler to notify once the Runnable has finished executing.Should not be null.
throws:
  IllegalStateException - if getThread() is null.



preemptAndWait
public void preemptAndWait(Runnable r, RunnableHandler runHandler) throws InterruptedException(Code)
Waits until the given Runnable's run() has returned. The given runnable preempts any runnable that is not currently executing (ie the next runnable started will be the one given). Note: preemptAndWait() must not be called from the current thread (for example from the run() method of the argument).
Parameters:
  r - the Runnable to execute
Parameters:
  runHandler - the RunnableHandler to notify once the Runnable has finished executing.Should not be null.
throws:
  IllegalStateException - if getThread() is null or if thethread returned by getThread() is the current one.
throws:
  InterruptedException - if the thread is interrupted whilewaiting for the completion of the input Runnableto complete execution.



preemptLater
public void preemptLater(Runnable r, RunnableHandler runHandler)(Code)
Schedules the given Runnable object for a later invocation, and returns. The given runnable preempts any runnable that is not currently executing (ie the next runnable started will be the one given). An exception is thrown if the RunnableQueue was not started.
Parameters:
  r - the Runnable to put at the front of the execution list.
Parameters:
  runHandler - the RunnableHandler to notify once the Runnable has finished executing.Should not be null.
throws:
  IllegalStateException - if getThread() is null.



resumeExecution
public void resumeExecution()(Code)
Resumes the execution of this queue.
throws:
  IllegalStateException - if getThread() is null.



run
public void run()(Code)
Runs this queue. Implements the Runnable interface.



safeInvokeAndWait
public void safeInvokeAndWait(Runnable r, RunnableHandler runHandler)(Code)
Waits until the given Runnable's run() has returned. Note: safeInvokeAndWait() may be called from any thread. This method checks if this thread is the update thread, in which case the Runnable is invoked directly. Otherwise, it delegates to the invokeAndWait method.
Parameters:
  r - the Runnable to put at the end of the execution list. Should not be null.
Parameters:
  runHandler - the RunnableHandler to notify once the Runnable has finished executing.Should not be null.
throws:
  IllegalStateException - if getThread() is null or if thethread returned by getThread() is the current one.



scheduleAtFixedRate
public void scheduleAtFixedRate(Runnable r, RunnableHandler runHandler, long interval)(Code)
Schedules the input Runnable at the requested fixed rate. The RunnableQueue offers a 'best' effort service meaning that it will schedule the Runnable as soon as possible so that the time between the begining of two consecutive runs of the Runnable is as close as possible to the requested rate. Note that a too high rate may cause the rest of the Runnable in the RunnableQueue to be starved and never get executed.
Parameters:
  r - the Runnable to schedule at a regularinterval. If null, there won't be any Runnablescheduled and if there was a current one, it won't be executedany more.
Parameters:
  runHandler - the RunnableHandler to notify once the Runnable has finished executing.Should not be null.
Parameters:
  interval - the minimum interval between to consecutive executions of the input Runnable. The value is in milliseconds.
throws:
  IllegalArgumentException - If this parameter is zero or less, and r is not null.



suspendExecution
public void suspendExecution(boolean waitTillSuspended)(Code)
Suspends the execution of this queue after the current runnable completes.
Parameters:
  waitTillSuspended - if true this method will not returnuntil the queue has suspended (no runnable in progressor about to be in progress). If resumeExecution iscalled while waiting will simply return (this reallyindicates a race condition in your code). This mayreturn before an associated RunHandler is notified.
throws:
  IllegalStateException - if getThread() is null.



unschedule
public void unschedule(Runnable r)(Code)
Removes the input Runnable from the list of Runnables scheduled at a fixed rate. If the Runnable is not currently scheduled at a fixed rate, then this method does nothing. If this Runnable was scheduled multiple times with this RunnableQueue, then all instances are removed.
Parameters:
  r - the Runnable that should no longer be scheduled at a fixed rate.
See Also:   RunnableQueue.scheduleAtFixedRate



Methods inherited from java.lang.Object
public boolean equals(Object obj)(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.