Computing and Concurrent System Design (Java Threads)
Computing and Concurrent System Design (Java Threads)
Computing and Concurrent System Design (Java Threads)
Table of Contents
Table of Contents...............................................................................................................1 PROBLEM ANALYSIS.......................................................................................................3 2.0 REQUIREMENTS........................................................................................................4 3.0 ASSUMPTIONS...........................................................................................................6 4.0 PROPOSED SOLUTION...........................................................................................13 5.0 DESGIN.....................................................................................................................14 5.1 Class Diagram........................................................................................................14 5.2 Structure Diagram..................................................................................................15 6.0 PROGRAMMING TECNIQUES ................................................................................16 6..1 Design Patterns.....................................................................................................16 Singleton pattern.......................................................................................................16 Iterator pattern..........................................................................................................16 Faade pattern..........................................................................................................17 6.2 Static keyword........................................................................................................19 6.3 Getters and Setters................................................................................................20 6. 4 Constructors..........................................................................................................21 6.5 MVC Architecture...................................................................................................21 7.0 CONCURRENT PROGRAMMING CONCEPTS.......................................................22 7.1 Threads..................................................................................................................22 7.2 Thread Methods.....................................................................................................24 7.3 Synchronized methods...........................................................................................25 7.4 Condition Synchronization and Thread communication........................................27 8.0 CONCURRET PROGRAMMING DESGIN................................................................29
9.0 TESTING & OUTPUT................................................................................................35 10.0 SOURCE CODE LISTING.......................................................................................41 11.0 Depth discussion.....................................................................................................50 12.0 Critical appraisal......................................................................................................51 13.0 REFERANCES........................................................................................................54
PROBLEM ANALYSIS
Intention of this assignment is to develop a simulation application to represent the processes of an airport by automating the all the task of the Air Traffic Controller. All the business operations as an aircraft approaches an airport to leave the airport must be included in the simulation as real world scenario. Graphical representation of events is not required, but clear textual representations of describing the events are expected from the implementation.
2.0 REQUIREMENTS
Automated the tasks of the air traffic control system. Such as assigning paths to the aircrafts, perform takeoff, landing and holding pattern processes. Air Traffic Controller (ATC) systems should responsible for perform main tasks as an aircraft approaches an airport to leave the airport by completing every processes as quickly as possible. The air traffic simulation consists of airspace, one virtual path, two runways, hanger queue and number of flights. Aircraft does not collide with any other aircraft in any time. Ensure that the approaching aircraft is inserted smoothly into the traffic around the airport (around the controllers areas such as airspace, virtual path, runways and hanger areas). Every aircraft insertion should be cause to minimum of disruption to the flight paths of other aircrafts. Airspace, virtual path and hangers will serve for each flight which as in the order of first-comefirst-serve manner in every time as possible. FIFO rule should be break when special cases such as fuel problems, medical crises, aircraft mechanical malfunctions and changing weather conditions, occur on flights. Those aircrafts must be considered before than the other aircrafts. Therefore prioritization process should be encounter throughout the life cycle of the air traffic control system and updating should be done wherever as required. One set of ATC responsible for assigning flight paths to incoming aircrafts. Another ATC is responsible for guides those incoming aircrafts to holding patters or landing approaches. 4
Another ATC is for guides flights to a safe landing. Controllers always required communicating with each other and passing the handling of aircrafts with details when required.
Each controller belongs to a specific frequency range. Therefore pilots, operators and other controllers can identify each flights current responsible controllers by switching the frequency.
Each controller should responsible for provide all the required details clearly for pilots, operators and another controllers.
Since operators and pilots depend on those details rather watching the radar screen. According to this scenario airspace, virtual path. Runways and hangers should be the shared resources.
3.0 ASSUMPTIONS
This application will be representing an existing airport to make a simulation more realistic. Therefore at the beginning virtual path and hangers will be loaded with five flights and random number of flights (the range of 0 - 12) will arrive to the air space at once. In other words virtual path and hanger queues are already filled with five aircrafts and some numbers of flights are arriving in to the airspace after authenticated by the proposed airports simulators at the beginning of the application. Therefore existing flights of virtual path and hanger queues are considered before any other aircrafts in any case of this application by assuming those flights are waiting long time than newly arrived aircrafts).
This air traffic control system is fully automated and does not need any user input to performed tasks (all the required details are generated and retrieve by the sub controllers within the system).
This air traffic control system only needed the proposed airport processes and do not consider and communicate with other airports air traffic simulators. Therefore the following processes will not considering in this application Communicate with the air traffic control systems that reached by the flights which request for land at the represented airport. Communicate with the neighbor air traffic control systems to guide the flights which request for reach the distance of the proposed airport. After arriving to the airspace by completing the takeoff process.
Whole air traffic control processes will be handling by four air traffic simulators. Those are called as air space controller, virtual path controller, runway controller and hanger controller. As same as the name implies all the controllers are responsible for handling traffic around their corresponding areas (such as air space controller is responsible for handling air traffic around the airspace).
Airspace controller is responsible for authenticating the flights within the range of the airport, assigning path to flights which request for landing at the proposed airport, assigning path to flights which request for reach the distance of the airport, guided those flights until reach the controller area on assigned path, check emergency flights, check flights required to move on to the virtual path, provide the flight path details to hanger controller to perform the takeoff, set priorities according to the flights status and hand over the handling to next controller of a particular flight with details when required.
Virtual path controller is responsible for authenticating flights which request to arrive into the virtual path, assigning path for those flights, guided those flights until reach the controller area on assigned path, check availability in virtual path, provide the virtual path details to airspace controller, check emergency flights, check flights required to land, set priorities according to the flights status and hand over the handling to next controller of a particular flight with details when required.
Runway controller is responsible for guide assigned aircraft on to an assigned runway, check runway availability, clear the runway as soon as possible when complete the takeoff process or landing process and provide the runway details to hanger controller and virtual path controller.
Hanger controller is responsible for guide the aircrafts on to an assigned hanger queue, provide the hanger details to virtual path controller, check availability in hanger queues, check 7
and set the priorities of flights, check flights required to takeoff and provide the takeoff flights details to the airspace controller. Controllers are always communicating with each other and provide the handling responsible for next controller when aircraft is needed to reach one controller area to another controller area by authenticating specific aircraft with its details.
This airport has only one virtual path and two runways. To make the simulation easy to understand, flights are named with their responsible areas. Such as airspace flights are named as AF, virtual path flights are named as VF and hanger flights are named as HF. Moreover one flight ID will not use again and again. (i.e. after flight AF1 is successfully complete the takeoff process flight ID AF1 will not appear again).
The actual time line is not considering in this application and flights are move around without any delay of time.
The spaces between flights are do not cause to occur any aircraft collisions.
Airspace is conceptually divided in to paths using altitude, direction and the path range of 20 units such as 0-20, 21-40. Those paths will be assigning for flights which use the represented airspace and one path will assign only for one flight and path range unit will be not exceeding the upper bound number.
Airspace can be used for flights which required to land at the represented airport, required to reach the distance of the airspace and takeoff flights. Different altitude paths (5000ft paths are assigned for landing flights, 8000ft paths are assigned for reaching / not landing flights and 3000ft paths are assigned for takeoff flights) are used to avoid aircraft collisions between those flights.
All the aircrafts belongs to airspace controller area required to switch on the frequency range of 6000Hz 6500Hz. Therefore pilots, operators and other controllers can identify each flights current responsible controller by switching the frequency.
All the airspace flights are guided and move around only on assigned path.
The flights will not meet with any disruption during the way of airspace to virtual path. Any number of flights can be arriving to the airspace.
Virtual path and hanger queues are capable of handling a maximum of 10 flights. Virtual path is also conceptually divided in to ten positions / paths and those are indicated using numbers (0 - 9).
All the aircrafts belongs to virtual path controller area required to switch on the frequency range of 5000Hz 5500Hz. Therefore pilots, operators and other controllers can identify each flights current responsible controller by switching the frequency.
One position will only assigned for one flight at a time to avoid aircraft collisions in virtual path.
All the virtual path flights are guided and move around only on assigned path. 9
Virtual path is used for sorting purpose. In other words virtual path is used to handle flights until prioritization and landing processes will complete.
The flights will not meet with any disruption during the way of virtual path to runway.
Both runways are used to perform takeoff and landing processes. All the aircrafts belongs to runway controller area required to switch on the frequency range of 4000Hz 4500Hz. Therefore pilots, operators and other controllers can identify each flights current responsible controller by switching the frequency.
Once complete the takeoff process (after release the runway) the flights will not meet with any disruption until arrive to the airspace.
Once complete the landing process (after release the runway) the flights will not meet with any disruption until reach to the hanger queue.
Hangers will be assigned at the virtual path for landing flights to avoid aircraft delay of time and one queue will issue only for one flight to avoid aircraft collisions in the hangers.
10
All the aircrafts belongs to hanger controller area required to switch on the frequency range of 3000Hz 3500Hz. Therefore pilots, operators and other controllers can identify each flights current responsible controller by switching the frequency.
Successfully complete the landing process once, the flights are quickly move to the assigned queue without any delay and clean the runway for next flight to perform the task.
Every special case such as fuel problems, medical crises, changing weather conditions and aircraft mechanical malfunctions are consider as the same status and provide highest priority for those aircrafts. If there are more than one emergency case occurred in any given time, priority will be assigned based on the FIFO (First In First Out) pattern.
Since proposed air traffic simulators represent the existing airport, the virtual path existing emergency aircrafts will be considering first. (By assuming those flights are waiting long time than newly arrived aircrafts).
Flights are stop in the hanger queues according to the order. Such as the hanger queue number 0 is assigned for the firstly arrived flight and next queue for the next flight.
Since proposed air traffic simulators represent the existing airport, random waiting time will assign for existing virtual path flights as a solution to the priority problem at the beginning. Therefore value with highest waiting time is the flight that waits for a long time and required to be assigned as highest priority flight (after the emergency flights).
11
The firstly arrived flight in to the airspace is the flight that required to be assigned as highest priority flight (after the emergency flights).
User manual will helpful for the operators since they dont have much knowledge of the computer based system and fully automated system.
Operators are not need to input any details and manual decisions do not affect (and reflect) to the proposed system.
12
Solution to above stated problem should be providing using appropriate concurrent program design concepts and methods using Java language (according to the requirement specified in the assignment). In other words simulation should be representing the concurrent access of flights and controllers as the real world scenario. Object oriented concepts of Java language can be used in order to satisfy the appropriateness of the implementation. The solution design is described with the structured and class diagrams, FSPs, LTSs and those explanations are described in the following chapters.
13
5.0 DESGIN
14
15
This concept were used in all the classes including the classes which holding the shared resources. Above code example was used to create a singleton instance for air space controller class. Since other controller classes required to access the information of airspace controller class and those are threads it is must require using one instance in everywhere.
Iterator pattern As described by the (Gamma, E. et al. 1999: P.23 P. 24) iterator provides ways to access elements of object member by sequential manner without exposing to the underlying structure of the object. 16
Hanger queue class used an array list to hold the flights which are in the hanger queues. Hanger controller class access that queue to get the details of flights which is stop at those hanger queues. (All the other shared resources such as airspace and virtual path used the same concept and all the ATC controllers were accessing those array lists to retrieve the flight details). Since controllers are iterate through the queue to retrieve specific flight details until reach the size of the array list. Iterator patterns concept is directly used the java iterator. In proposed system implementation used several iterators to retrieve the aircrafts details. E.g.:
(Note: only the relevant code to demonstrate pattern is listed) Faade pattern According to (Gamma, E. et al. 1999: P.15 P. 16) faade defines a unified, higher level interface to a subsystem to make it easier to use. In the given scenario Air Traffic Controllers are responsible to perform as coordinators between the shared resources (airspace, virtual path, 17
runways and hanger queues) and aircrafts. In other words Air Traffic Controllers are act as a faade or unified interface to each of the flight involve in the system. Therefore flights do not required to direct contact with the shared resource details is the major advantage of this pattern. Since controllers can handle all the resources (shared resources and aircrafts) is caused to increase the efficiency of the concurrent execution. E.g.: the method public synchronized boolean check_availability_in_virtualPath () {} Is used to check the availability status on the virtual path and implemented within the airspace controller class.
When flight is request to move on to virtual path, airspace controller will check with this method and pass the details to the requested flight.
E.g.:
18
When considering the requirements of the given scenario, should be able to retrieve the specific aircraft details from any responsible ATC controller class. As an example when flight required 19
moving to virtual path, it must have the same details of that particular flight in the virtual path controller class as same as in the airspace controller class. Static keyword used to accomplish this task. In this implemented code used static keyword for class members which required to be used independently of any object of that class. Also it provides the advantage of accessing particular class member before any objects of its class are created. E.g.:
Static variable is used for flight ID since those are required to be specific. Therefore all the classes are shared the same static variable for the flight ID. E.g.:
other words limit the access for shared resources by placing private access modifier. Since used the public getters and setters for access those shared resources. E.g.:
6. 4 Constructors
At the time of creating flights it should require identifying each one specifically. Therefore constructor of flights class used to define the each flights ID and emergency status as those are major requirements of this ATC system. E.g.:
21
controller. The model is the application object, the view is its screen representation and the controller places in between of model and view by controlling those. According to the implementation of the ATC, it used shared resource classes as model objects such as airspace queue, virtual path queue, runways and hangers queue. Also used user manual and ATC_view classes as view objects and controller classes such as airspace controller, virtual path controller, runway controller and hanger controller as controller objects. E.g.: model objects (classes)
22
According to (Meyer, B. et al 2010: P.5) Creating a thread is the base for concurrency. To achieve it more efficiently can create threads for the objects in the application which required executing concurrently. Therefore several thread instances were used in this application. As described by the (Meyer, B. et al 2010: P.5) as same as every java program consists of at least one thread which executes the main () method, proposed solution also used main thread is the thread which resulted in starting the execution of whole program. It could achieve by using,
According to the (developperWorks, nd: P.4) though there are two ways of implementing concurrency by implementing runnable Interface and extending from Thread class, proposed solution uses the second way (extending from Thread class) throughout the implementation to create concurrency. E.g.:
As described by the (Meyer, B. et al 2010: P.5) after inherit from the thread class, should override the run () method to complete the process. Run () is the most important part of the Thread implementation since all the functionalities must include within that (Costa, P. nd: P.7). E.g.:
To run the thread must invoke the start () method on the run () of the object (Meyer, B. et al 2010: P.6). Eg:
23
According to above stated features, thread representation of the proposed solution is as follows.
E.g.:
(Note: only the relevant code to demonstrate above is listed) E.g.: Local object references
25
But following resources are shared by the threads in the code implementation. Object members
Methods of the classes / object instances Most of the object members are public to all other external threads. Therefore those object members are not threaded safe. (There is no any risky object member in the proposed implementation). According to (Meyer, B. et al 2010: P.9) and (developperWorks, nd: P.30) this problem can be avoid using the concept of synchronization. Synchronization is the process will ensure that only one thread can access the data at one time. To achieve that it uses the lock of the object. Synchronization will locked the one thread at a time and others have to wait until complete the task. This called as mutual exclusion. As described by the (Meyer, B. et al 2010: P.9) though java provide two ways to achieve mutual exclusion via synchronization as synchronized methods and synchronized block, this implementation used the synchronized methods only. All the ATC controller classes are used synchronized methods since those are used shared resources. E.g.: Air space controller class has following synchronized methods.
26
When required to execute a block of code continuously or until reach some condition, the condition synchronization can be used. It benefits to stay inside the loop until satisfy the task. E.g.:
Most of the time when accessing the condition synchronization it must requires performing interthread communication to complete the tasks (Jennery, K. B., 2003: P.52). Java highly supports to achieve inter-thread communication by enabling some methods (Meyer, B. et al 2010: P.10). Those are as follows. Wait () As described by the (Schmidt, D.C. nd: P.35 - P.36) wait () result in following actions. The current thread is suspended Waits for a condition to be satisfied. 27
Release the synchronization lock associated with the monitor object. Wait () method is used to perform inter-thread communication in implemented code.
E.g.:
After perform the main task of the above method wait () call gets executed. Then current thread state become blocked and releases the lock and provides handling to another thread to execute on this method. To increase the accuracy of the mutual exclusion, customized wait () method is used
E.g.:
Notify () As described by the (Meyer, B. et al 2010: P.11) wakes up a single thread that is waiting on this objects set. When particular thread is awakened, still it cannot require the lock until the previous method releases the lock. The weak point of notify () is to developer do not know which thread will wake up. But this method used in this application by customizing notify () method. 28
E.g.:
In this method notify a waiting thread vpc (virtual path controller) but does not yet release the lock of the current object. However eventually the current thread will release the lock by leaving the synchronized block, unblocked vpc thread can acquire the lock of the method.
29
assign_runway_one->assign_hanger_queue->landing-leave_runway_onestop_in_hanger_queue ->FLIGHT_LANDING |runway_two -> assign_runway_two ->assign_hanger_queue->landingleave_runway_two->stop_in_hanger_queue ->FLIGHT_LANDING |runways_busy ->waitng_in_virtualPath ->FLIGHT_LANDING
Takeoff process
|runway_two
->
assign_runway_two
->takeOff->leave_runway_two-
arrive_to_airspace->FLIGHT_TAKEOFF
30
31
32
Takeoff process
33
Event
Concurrent Programming Design
Success
Random number of (up to 12) flights are add once to the airspace Five number of flights are add once (existing flights) to the virtual path Sort the virtual flights according to the waiting time Five number of flights are add once (existing flights) to the hangers Flights enter airspace (newly created) at regular intervals Flights IDs are statically create (flight IDs are unique) Emergency status of flights are randomly generated Altitude of flights are randomly generated Frequencies are auto generated Direction of flights are randomly generated Flights which required to reach the distance of the airport are created and display Delete reaching flights after displaying from the airspace queue class. Check emergency flights in the virtual path (store emergency flights in temporary list) Display Currently there are no any emergency flights in virtual path if no any emergency flights. Check emergency flights in the airspace (store temporary list) Display Currently there are no any emergency flights in airspace if no any emergency flights. 34 Correctly assign hanger queues for virtual emergency flights Correctly assign runways for virtual emergency flights emergency flights in
x x
35
36
Airspace controller
37
ATC View
38
39
Hanger controller
40
User_manual_previw is the startup thread. It includes the instruction details of the ATC system in the run () and run on the User_Manual GUI.
Before end of the run () method of User_manual_previw, included the start () methods of Air_sapce_controller, Virtual_path_controller, Runway_controller and Hanger_controller 41
thread instances. Therefore after executing the User_manual_previw instruction, all the controllers threads are starting to run. At the same time User_Manual GUI become invisible and ATC_GUI become visible to the user.
At the beginning of the application required to represent some aircrafts around the airport since the designed ATC system represents the existing airport. ATC_view is a thread class and it provides the data sets for all controller classes to achieve the simulation purpose. Those methods are as follows. The following add_flights_to_airSpace () method create random number of flights (up to 12) at once and add to the airspace at the beginning (to represent the some number of flights arriving at the first stage of the application).
42
The add_flights_to_virtual () method which is in the ATC_view class, add five aircrafts to the virtual path at the beginning. ATC_view class has method call add_flights_to_hanger () which same as the add_flights_to_virtual () to add five aircrafts to the hanger queue at the beginning.
Adding flights in to airspace, virtual path and hangers will be happen in parallel.
Create new flights at regular intervals using add_flights () method which is in ATC_view class until close the application. This method used the keyword synchronized because, when flight is complete the takeoff process it should be display in the airspace before leave the airport. Therefore both methods add flights to the airspace queue (takeoff method and add_flights method) since both are thread instance, it should be ensure to avoid the race conditions.
43
After adding the (existing) flights in to controller areas, airspace and virtual path controllers are responsible to check the emergency flights and provide the priority for each flight by checking flight details. Airspace controller check the emergency flights by using check_emergency_flights_in_airSpace () method and it used synchronized because it try to add flights to the virtual path. At the same time virtual path controller will check for the emergency flights which is in the virtual path by using check_emergency_flights_in_virtualPath () method.
44
After checking emergency flights in the airspace, airspace controller thread will wait until virtual path emergency flights land. Within the direct_emegency_flights_from_virtualPath_to_runway () method both hanger queue and runway will assign for emergency flights. Emergency flights have to wait either runway or hanger queue will not be available at that time. This method used synchronization since it accesses the runways (shared resources).
At the beginning runway controller thread forced to wait since there is no any flight checked to perform landing process. Therefore after completing the execution of direct_emegency_flights_from_virtualPath_to_runway () method (after checking all the emergency flights in the virtual path) will inform to the runway controller to perform its task. After notifying the runway controller it will give chance to the
45
After successfully completing the landing process of the virtual emergency flights, runway controller handover the control to the virtual path controller. direct_emegency_flights_from_airSpace_to_runway () method of the virtual path controller will follow the same process as same as the direct_virtual_emegency_flights_from_runway_to_hanger () method to direct the flights with emergency that occur in the airspace to the runways. This method used the synchronization since it accesses the shared resources. To complete the landing process virtual path controller will hand over the control to runway controller. direct_airSpace_emegency_flights_from_runway_to_hanger () method follow the same process as same as the direct_virtual_emegency_flights_from_runway_to_hanger () method to direct those emergency flights to hanger queues. After successfully completing the landing process runway controller will hand over the control again to the virtual path controller.
46
The method check_flights_need_to_move_runway () will check virtual path flight priorities (without emergency) to identifying the flights which required to land.
After checking priorities of the virtual path flights hand over the control to airspace controller by waiting virtual path controller until gets informed. Then airspace controllers check_flights_need_to_move_virtualPath () method follow the same process to check flight priorities of airspace flights. It used the synchronization since it access the virtual path.
47
After complete the flight prioritization in the airspace, it will notify the virtual path controller by handing over the control. Then virtual path controllers direct_normal_flights_from_virtualPath_to_runway () method assign the virtual flights which get high priority (flights with highest waiting time) to runways and hangers in order to perform the landing process.
48
When taking the control from virtual path controller, runway controller performs the landing process. direct_virtual_normal_flights_from_runway_to_hanger () method used to do that task.
Then again handover the control to virtual path controller to direct the highest priority flights which was in the airspace. It can be done by using virtual path controllers direct_normal_flights_from_airSpace_to_runway () method. Then it follow the same process as same as the direct_virtual_normal_flights_from_runway_to_hanger () method.
49
As stated in the assumptions I have ensure the aircrafts are inserted smoothly into the traffic around the airport by giving specific paths and positions in the airspace and the virtual path. (More details are in the assumptions section). (Only need to worry those two areas due to moving large number of flights around. Runways areas and hangers areas have less number of flights). As expected in the requirements I have provide the proper prioritization process in each controller class. Since I have designed existing airport I have provided high priority to virtual path emergency flights, then airspace emergency and then the normal flights. When processing prioritization for normal flights, I have used the FIFO pattern and I have broken the rules only in emergency situation. Finally I have not provided continuously execution of the system due to simplified the simulation. When considering the requirements and the implementation of the designed system I believe I could achieve most of those.
system. Also it was quite hard to implementing the concurrency concept in a standalone application with ensuring the concurrent requirements. Since Java provide highly flexible environment for implementing concurrency it was reduce the complexity of the problem. The modeling techniques that required using in this scenario were LTS and FSP which I had never learned before. Therefore it was also quite hard to learn since more resources not available. However when the time of implementing the system I have learned most of the concurrent concepts and how to apply those. The above stated chapters explained those concepts and code examples that applied by the system. I liked to state some statements here about the concurrent concepts which I did not use in my implementation and reasons for those. Runnable Interface According to (Costa, P. nd) there is little difference between the implementation of threads using the two approaches even doing the same thing in the threading API. As moreover explained by the (Costa, P. nd) by extending the thread class, the derived class itself is a thread object and it gains full control over the thread life cycle. When implementing the runnable interface class does not provide any control over the thread itself. Since java does not support for multiple inheritance extending the thread class eliminate the chance for inherit from any other class. It does not occur when implementing runnable interface. Because of using implementation, there is a chance to extending from another class. But for proposed solution does not use any other inheritance rather than the thread class. Also it highly used thread states such as start (), wait (), notify (), sleep () to control the thread execution. When considering above reasons, the approach of extending from the thread class is more suitable for proposed solution. Thread priority According to the (Meyer, B. et al 2010) thread priority can be used for assigning order for threads. But as explained by the (developperWorks, nd: P.9) this is not guarantee. Therefore this implementation does not use thread priority (only use the default priority value 5).
52
Thread methods Following thread methods are do not use in the implementation o Yield () causes the current thread to move from the running state to runnable state. o Interrupted () force to thread to change o Suspend () suspend the thread o Stop () terminate the thread Those are force to change the thread states and interrupt to the execution flow of the application. Also may cause to loss or corrupt the data. Therefore those were not applied in this proposed solution.
Synchronization block As described by the (Costa, P. nd: P.18) synchronized blocks can be used to lock current thread as well as the any given thread by taking as argument of which object to lock. But synchronized methods can be used to lock the current thread. According to (Schmidt, D.C. nd: P.32 - P.34) in Java, block synchronization is considered to be a more basic construct than method synchronization. Because of only the shared resource is lock by the method block. It is rather risky than method block. Therefore in the proposed solution implementations used only synchronize methods.
notifyAll ()
53
This method wakes up all threads that are in waiting mode (Costa, P. nd: P.58). Therefore this not used in implementation of the proposed solution due to increase the accuracy of mutual exclision.
Finally this was good start for concurrent programming and was quite interesting programming period by created an interest in me about the concurrent environment. However there are still a lot more in concurrent programming that still remains to be explored.
13.0 REFERANCES
54
Aldrich, J. (2005). Design patterns. [Online] available from: http://www.google.lk/url? sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CF4QFjAB&url=http%3A%2F %2Fwww.cs.cmu.edu%2F~aldrich%2F214%2Fslides-aldrich%2F11-designpatterns.pdf&ei=1IbMTr3O8SmrAeG8ayeDg&usg=AFQjCNGbowXe0KmGpa6JxWWzggL1x8YOwg&sig2=PQCri4OyzFMox32JJ1CWA. [Accessed 1/06/2012]. Costa, P. (nd). Concurrent programming in java. .[Online] available from: http://www.google.lk/url? sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CE4QFjAA&url=http%3A%2F %2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.187.6218%26rep %3Drep1%26type%3Dpdf&ei=5VDLT-avGoJrAeF1oHRDg&usg=AFQjCNG_uIvIhsEooAxic4hwj0R6gLEOEw&sig2=WQLDrIQ8NItmnwq3I Py3rQ. [Accessed 31/05/2012]. developperWorks, (nd). Concurrent programming in the Java language. .[Online] available from: http://www.google.lk/url? sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CFAQFjAA&url=http%3A%2F %2Fcarfield.com.hk%2Fdocument%2Fjava%2Ftutorial%2FThread %2FAdvance_thread.pdf&ei=4UPLT56QF8nlrAfa-4nBDg&usg=AFQjCNHuzXCEAzllnPKL9KZtdAYTqEGkQ&sig2=7Hu1m_aC4mEbG6Y2Eug1Vw. [Accessed 31/05/2012]. Gallardo, D. (nd). Java design patterns.[Online] available from: https://www.google.lk/url? sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CFQQFjAB&url=https%3A%2F %2Fwww6.software.ibm.com%2Fdeveloperworks%2Feducation%2Fj-patterns%2Fj-patternsltr.pdf&ei=FmXMT577PIaHrAfv9uCfDg&usg=AFQjCNF1xNHJYH7wuqdiV1fOTKy9lGaXA&sig2=QMON-GFssV7M2nKJHyY_Ew. [Accessed 1/06/2012]. Gamma, E., Helm, R., Johnson, R. (1999). Design patterns elements of reusable Object Oriented software. [Online] available from: http://www.google.lk/url? sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CFwQFjAA&url=http%3A%2F %2Fwww.uml.org.cn%2Fc%2B%2B%2Fpdf
55
%2FDesignPatterns.pdf&ei=n2nMT_CGIYjxrQeY3rmvDg&usg=AFQjCNEwKV3ToLmt85RL31 y52Vrc6fKJ0Q&sig2=D7l9rJ7FmTF6i-Do1Oijnw. [Accessed 1/06/2012]. Jennery, K. B., (2003). Multi-Threaded concurrency in Java.SunMicrosystems. .[Online] available from: http://www.google.lk/url? sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CFUQFjAA&url=http%3A%2F %2Fwww.softwaresummit.com%2F2003%2Fspeakers %2FJenneryMultithreading.pdf&ei=fDXMT9GbL4jNrQe4y4mfDg&usg=AFQjCNH4cEnHT2T_ ZCP4_bXnt8_QsonX1w&sig2=Qf71ctTwmYhCzTcEtdwG5A. [Accessed 1/06/2012]. Meyer, B., Pedroni, M. (2010). Concurrent Programming with Java Threads.[Online] available from: http://www.google.lk/url? sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CE8QFjAA&url=http%3A%2F %2Fse.inf.ethz.ch%2Fold%2Fteaching%2F2010-S%2F0050%2Fslides %2F13_softarch_self_study_threads.pdf&ei=l0DLT7OUC4rZrQfE3IC2Dg&usg=AFQjCNFAf6h8 eludGb-tYJo9K2VRH7g2XQ&sig2=THojGGqkZvdSBOW9fWa42g. [Accessed 31/05/2012]. Schmidt, D.C. (nd). Concurrent programming with Java. .[Online] available from:http://scm0329.googlecode.com/svn-history/r130/trunk/book/concurrentprogramming.pdf. [Accessed 1/06/2012].
56