Source Code Cross Referenced for WaitableLong.java in  » Ajax » Laszlo-4.0.10 » EDU » oswego » cs » dl » 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 » Ajax » Laszlo 4.0.10 » EDU.oswego.cs.dl.util.concurrent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          File: WaitableLong.java
003:
004:          Originally written by Doug Lea and released into the public domain.
005:          This may be used for any purposes whatsoever without acknowledgment.
006:          Thanks for the assistance and support of Sun Microsystems Labs,
007:          and everyone contributing, testing, and using this code.
008:
009:          History:
010:          Date       Who                What
011:          23Jun1998  dl               Create public version
012:         */
013:
014:        package EDU.oswego.cs.dl.util.concurrent;
015:
016:        /**
017:         * A class useful for offloading waiting and signalling operations
018:         * on single long variables. 
019:         * <p>
020:         * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
021:         **/
022:
023:        public class WaitableLong extends SynchronizedLong {
024:            /** 
025:             * Make a new WaitableLong with the given initial value,
026:             * and using its own internal lock.
027:             **/
028:            public WaitableLong(long initialValue) {
029:                super (initialValue);
030:            }
031:
032:            /** 
033:             * Make a new WaitableLong with the given initial value,
034:             * and using the supplied lock.
035:             **/
036:            public WaitableLong(long initialValue, Object lock) {
037:                super (initialValue, lock);
038:            }
039:
040:            public long set(long newValue) {
041:                synchronized (lock_) {
042:                    lock_.notifyAll();
043:                    return super .set(newValue);
044:                }
045:            }
046:
047:            public boolean commit(long assumedValue, long newValue) {
048:                synchronized (lock_) {
049:                    boolean success = super .commit(assumedValue, newValue);
050:                    if (success)
051:                        lock_.notifyAll();
052:                    return success;
053:                }
054:            }
055:
056:            public long increment() {
057:                synchronized (lock_) {
058:                    lock_.notifyAll();
059:                    return super .increment();
060:                }
061:            }
062:
063:            public long decrement() {
064:                synchronized (lock_) {
065:                    lock_.notifyAll();
066:                    return super .decrement();
067:                }
068:            }
069:
070:            public long add(long amount) {
071:                synchronized (lock_) {
072:                    lock_.notifyAll();
073:                    return super .add(amount);
074:                }
075:            }
076:
077:            public long subtract(long amount) {
078:                synchronized (lock_) {
079:                    lock_.notifyAll();
080:                    return super .subtract(amount);
081:                }
082:            }
083:
084:            public long multiply(long factor) {
085:                synchronized (lock_) {
086:                    lock_.notifyAll();
087:                    return super .multiply(factor);
088:                }
089:            }
090:
091:            public long divide(long factor) {
092:                synchronized (lock_) {
093:                    lock_.notifyAll();
094:                    return super .divide(factor);
095:                }
096:            }
097:
098:            /**
099:             * Wait until value equals c, then run action if nonnull.
100:             * The action is run with the synchronization lock held.
101:             **/
102:
103:            public void whenEqual(long c, Runnable action)
104:                    throws InterruptedException {
105:                synchronized (lock_) {
106:                    while (!(value_ == c))
107:                        lock_.wait();
108:                    if (action != null)
109:                        action.run();
110:                }
111:            }
112:
113:            /**
114:             * wait until value not equal to c, then run action if nonnull.
115:             * The action is run with the synchronization lock held.
116:             **/
117:            public void whenNotEqual(long c, Runnable action)
118:                    throws InterruptedException {
119:                synchronized (lock_) {
120:                    while (!(value_ != c))
121:                        lock_.wait();
122:                    if (action != null)
123:                        action.run();
124:                }
125:            }
126:
127:            /**
128:             * wait until value less than or equal to c, then run action if nonnull.
129:             * The action is run with the synchronization lock held.
130:             **/
131:            public void whenLessEqual(long c, Runnable action)
132:                    throws InterruptedException {
133:                synchronized (lock_) {
134:                    while (!(value_ <= c))
135:                        lock_.wait();
136:                    if (action != null)
137:                        action.run();
138:                }
139:            }
140:
141:            /**
142:             * wait until value less than c, then run action if nonnull.
143:             * The action is run with the synchronization lock held.
144:             **/
145:            public void whenLess(long c, Runnable action)
146:                    throws InterruptedException {
147:                synchronized (lock_) {
148:                    while (!(value_ < c))
149:                        lock_.wait();
150:                    if (action != null)
151:                        action.run();
152:                }
153:            }
154:
155:            /**
156:             * wait until value greater than or equal to c, then run action if nonnull.
157:             * The action is run with the synchronization lock held.
158:             **/
159:            public void whenGreaterEqual(long c, Runnable action)
160:                    throws InterruptedException {
161:                synchronized (lock_) {
162:                    while (!(value_ >= c))
163:                        lock_.wait();
164:                    if (action != null)
165:                        action.run();
166:                }
167:            }
168:
169:            /**
170:             * wait until value greater than c, then run action if nonnull.
171:             * The action is run with the synchronization lock held.
172:             **/
173:            public void whenGreater(long c, Runnable action)
174:                    throws InterruptedException {
175:                synchronized (lock_) {
176:                    while (!(value_ > c))
177:                        lock_.wait();
178:                    if (action != null)
179:                        action.run();
180:                }
181:            }
182:
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.