Source Code Cross Referenced for PyLock.java in  » Open-Source-Script » jython » org » python » modules » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. JDK Core
2. JDK Modules
3. JDK Modules com.sun
4. JDK Modules com.sun.java
5. JDK Modules Platform
6. JDK Modules sun
7. Open Source Build
8. Open Source Graphic Library
9. Open Source IDE Eclipse
10. Open Source J2EE
11. Open Source JDBC Driver
12. Open Source Library
13. Open Source Library Database
14. Open Source Net
15. Open Source Script
16. Science
17. Security
18. Sevlet Container
19. SUN GlassFish
20. Swing Library
21. Web Services apache cxf 2.0.1
22. Web Services AXIS2
23. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java Source Code / Java Documentation » Open Source Script » jython » org.python.modules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        // Copyright (c) Corporation for National Research Initiatives
02:        package org.python.modules;
03:
04:        import org.python.core.*;
05:
06:        public class PyLock extends PyObject {
07:            private boolean locked = false;
08:
09:            //private Object lock = new Object();
10:
11:            public boolean acquire() {
12:                return acquire(true);
13:            }
14:
15:            public synchronized boolean acquire(boolean waitflag) {
16:                if (waitflag) {
17:                    while (locked) {
18:                        try {
19:                            wait();
20:                        } catch (InterruptedException e) {
21:                            System.err.println("Interrupted thread");
22:                        }
23:                    }
24:                    locked = true;
25:                    return true;
26:                } else {
27:                    if (locked) {
28:                        return false;
29:                    } else {
30:                        locked = true;
31:                        return true;
32:                    }
33:                }
34:            }
35:
36:            public synchronized void release() {
37:                if (locked) {
38:                    locked = false;
39:                    notifyAll();
40:                } else {
41:                    throw Py.ValueError("lock not acquired");
42:                }
43:            }
44:
45:            public boolean locked() {
46:                return locked;
47:            }
48:        }
w___w_w__.__j___a__v___a__2__s___.__c__o_m | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.