Source Code Cross Referenced for thread.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:        class FunctionThread extends Thread {
07:            PyObject func;
08:            PyObject[] args;
09:            PySystemState systemState;
10:
11:            public FunctionThread(PyObject func, PyObject[] args) {
12:                super ();
13:                this .func = func;
14:                this .args = args;
15:                this .systemState = Py.getSystemState();
16:            }
17:
18:            public void run() {
19:                Py.setSystemState(systemState);
20:                try {
21:                    func.__call__(args);
22:                } catch (PyException exc) {
23:                    Py.printException(exc);
24:                }
25:            }
26:        }
27:
28:        public class thread implements  ClassDictInit {
29:            public static PyString __doc__ = new PyString(
30:                    "This module provides primitive operations to write multi-threaded "
31:                            + "programs.\n"
32:                            + "The 'threading' module provides a more convenient interface.");
33:
34:            public static void classDictInit(PyObject dict) {
35:                dict.__setitem__("LockType", PyType.fromClass(PyLock.class));
36:            }
37:
38:            public static PyObject error = new PyString("thread.error");
39:
40:            public static void start_new_thread(PyObject func, PyTuple args) {
41:                Thread pt = new FunctionThread(func, args.getArray());
42:                PyObject currentThread = func.__findattr__("im_self");
43:                if (currentThread != null) {
44:                    PyObject isDaemon = currentThread.__findattr__("isDaemon");
45:                    if (isDaemon != null && isDaemon.isCallable()) {
46:                        PyObject po = isDaemon.__call__();
47:                        pt.setDaemon(po.__nonzero__());
48:                    }
49:                    PyObject getName = currentThread.__findattr__("getName");
50:                    if (getName != null && getName.isCallable()) {
51:                        PyObject pname = getName.__call__();
52:                        pt.setName(String.valueOf(pname));
53:                    }
54:                }
55:                pt.start();
56:            }
57:
58:            public static PyLock allocate_lock() {
59:                return new PyLock();
60:            }
61:
62:            public static void exit() {
63:                exit_thread();
64:            }
65:
66:            public static void exit_thread() {
67:                throw new PyException(Py.SystemExit, new PyInteger(0));
68:            }
69:
70:            public static long get_ident() {
71:                return Py.java_obj_id(Thread.currentThread());
72:            }
73:        }
w_w___w__.__j_a__v_a2___s_._c_om__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.