您的位置:寻梦网首页编程乐园Java天地Core JavaJava Lecture Notes

Introduction

Content

Apply

Reflect

Extend

previous.gif
 (3087 bytes)

next.gif
 (2959 bytes)


Content Index

Content Page # 11

The execution of software systems

As it executes an object-oriented system creates and destroys objects. (You can imagine Notepad objects being created as you start the accessory application and being destroyed when you close it.) Since each object takes up a portion of a computer’s resources, objects are often destroyed when no longer needed while the program goes on to perform other tasks. Ultimately when a program terminates, the operating system tidies up its resources by destroying any objects left by the program. Java, like Smalltalk, but unlike C++, takes care of the recycling of resources for you by a process called garbage collection. Roughly, the way this works is that resources required for an object – the information it holds and the behaviour it provides – are reclaimed when all other objects no longer use it. For example, in a banking system the software would have to remember the objects that represented accounts and all of these would use physical storage. When an account is closed the object representing it does not need to remembered anymore and in the background Java arranges for its resources to be collected as garbage.

Objects send messages to each other to cause particular behaviour to occur. Associated with the concept of a message are those of the objects that are the sender and receiver of the message. An object has a set of messages that it knows how to respond to called its protocol. An object will only evoke some behaviour for valid messages it receives – i.e. messages that are within its protocol. The object that is a receiver of a message usually sends a reply (answer) back to the sender of the message.

The behaviour of an object will vary depending on its state at the time of receiving a message.

Back to top

basicline.gif (169 bytes)

RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg