Source Code Cross Referenced for oldclassic.java in  » Code-Analyzer » javapathfinder » gov » nasa » jpf » mc » 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 » Code Analyzer » javapathfinder » gov.nasa.jpf.mc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package gov.nasa.jpf.mc;
002:
003:        //
004:        // Copyright (C) 2005 United States Government as represented by the
005:        // Administrator of the National Aeronautics and Space Administration
006:        // (NASA).  All Rights Reserved.
007:        // 
008:        // This software is distributed under the NASA Open Source Agreement
009:        // (NOSA), version 1.3.  The NOSA has been approved by the Open Source
010:        // Initiative.  See the file NOSA-1.3-JPF at the top of the distribution
011:        // directory tree for the complete NOSA document.
012:        // 
013:        // THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
014:        // KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
015:        // LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
016:        // SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
017:        // A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
018:        // THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
019:        // DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
020:        //
021:
022:        /**
023:         * This example shows a deadlock which occurs as a result of a missed signal.
024:         * It also contains an assertion check that shows the race violation that is the
025:         * cause for the missed signal (and ultimate deadlock)
026:         * @author wvisser
027:         */
028:        public class oldclassic {
029:            public static void main(String[] args) {
030:                Event new_event1 = new Event();
031:                Event new_event2 = new Event();
032:
033:                FirstTask task1 = new FirstTask(new_event1, new_event2);
034:                SecondTask task2 = new SecondTask(new_event1, new_event2);
035:
036:                task1.start();
037:                task2.start();
038:            }
039:        }
040:
041:        /**
042:         * DOCUMENT ME!
043:         */
044:        class Event {
045:            int count = 0;
046:
047:            public synchronized void signal_event() {
048:                count = (count + 1) % 3;
049:                notifyAll();
050:            }
051:
052:            public synchronized void wait_for_event() {
053:                try {
054:                    wait();
055:                } catch (InterruptedException e) {
056:                }
057:
058:                ;
059:            }
060:        }
061:
062:        /**
063:         * DOCUMENT ME!
064:         */
065:        class FirstTask extends java.lang.Thread {
066:            Event event1;
067:            Event event2;
068:            int count = 0;
069:
070:            public FirstTask(Event e1, Event e2) {
071:                this .event1 = e1;
072:                this .event2 = e2;
073:            }
074:
075:            public void run() {
076:                count = event1.count;
077:
078:                while (true) {
079:                    if (count == event1.count) {
080:                        assert (count == event1.count);
081:                        event1.wait_for_event();
082:                    }
083:                    count = event1.count;
084:                    event2.signal_event();
085:                }
086:            }
087:        }
088:
089:        /**
090:         * DOCUMENT ME!
091:         */
092:        class SecondTask extends java.lang.Thread {
093:            Event event1;
094:            Event event2;
095:            int count = 0;
096:
097:            public SecondTask(Event e1, Event e2) {
098:                this .event1 = e1;
099:                this .event2 = e2;
100:            }
101:
102:            public void run() {
103:                count = event2.count;
104:
105:                while (true) {
106:                    event1.signal_event();
107:                    if (count == event2.count) {
108:                        assert (count == event2.count);
109:                        event2.wait_for_event();
110:                    }
111:                    count = event2.count;
112:                }
113:            }
114:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.