Game Development Reference
In-Depth Information
A method that has been declared using the abstract modifier keyword is a method
that has been declared for use in subclasses but that has no current implementation.
This means that it will have no Java code inside its method body, which, as you know,
is delineated in Java by using curly braces. Any subclass that extends an abstract class
must implement all these abstract methods, unless the subclass is also declared ab-
stract, in which case the abstract methods are passed down to the next subclass level.
Java's Volatile Modifier: Advanced Multithreading Con-
trol over Data Fields
The Java volatile modifier keyword is used when you are developing multithreaded ap-
plications, which you are not going to be doing in basic game development, as you
want to optimize your game well enough so that it only uses one thread. The volatile
modifier tells the Java virtual machine (JVM), which is running your application, to
merge the private (that thread's) copy of the data field (variable or constant) that has
been declared volatile with the master copy of that variable in system memory.
This is similar to the static modifier keyword, the difference being that a static vari-
able (data field) is shared by more than one object instance, whereas a volatile data
field (variable or constant) is shared by more than one thread.
Java's Synchronized Modifier: Advanced Multithread-
ing Control over Methods
The Java synchronized modifier keyword is also used when you are developing multi-
threaded applications, which you are not going to be doing for your basic game devel-
opment here. The synchronized modifier tells the JVM, which is running your applica-
tion, that the method that has been declared synchronized can be accessed by only one
thread at a time. This concept is similar to that of synchronized database access, which
prevents record access collisions . A synchronized modifier keyword likewise prevents
collisions between threads accessing your method (in system memory) by serializing
the access to one at a time so that parallel (simultaneous) access to a method in
memory by multiple threads will never occur.
Now that you have studied primary Java constructs (classes, methods, and fields)
and basic modifier keywords (public, private, protected, static, final, abstract, and so
on), let's journey inside the curly braces now, learning about the tools that are used to
Search WWH ::




Custom Search