Java Language Specification 中的关键字列表:
[url]http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.9[/url][quote]3.9 Keywords
[color=red][b]50[/b][/color] character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (§3.8).:
Keyword: one of
abstract continue for new switch
assert default if package synchronized
boolean do goto private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while
[color=red]The keywords [b]const[/b] and [b]goto[/b] are reserved, even though they are not currently used[/color]. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.
[color=red]While [b]true[/b] and [b]false[/b] might appear to be keywords, they are technically[b] Boolean literals[/b][/color] (§3.10.3). Similarly, [color=red]while [b]null[/b] might appear to be a keyword, it is technically the [b]null literal[/b][/color] (§3.10.7).[/quote]
transient,volatile:
[url]http://stackoverflow.com/questions/106591/do-you-ever-use-the-volatile-keyword-in-java?rq=1[/url]
[quote]When is volatile enough?
If two threads are both reading and writing to a shared variable, then using the volatile keyword for that is not enough. You need to use synchronization in that case to guarantee that the reading and writing of the variable is atomic.
But in case one thread reads and writes the value of a volatile variable, and other threads only read the variable, then the reading threads are guaranteed to see the latest value written to the volatile variable. Without making the variable volatile, this would not be guaranteed.
Performance considerations of using volatile:
Reading and writing of volatile variables causes the variable to be read or written to main memory. Reading from and writing to main memory is more expensive than accessing the CPU cache. Accessing volatile variables also prevent instruction reordering which is a normal performance enhancement technique. Thus, you should only use volatile variables when you really need to enforce visibility of variables.[/quote]
[url]http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.9[/url][quote]3.9 Keywords
[color=red][b]50[/b][/color] character sequences, formed from ASCII letters, are reserved for use as keywords and cannot be used as identifiers (§3.8).:
Keyword: one of
abstract continue for new switch
assert default if package synchronized
boolean do goto private this
break double implements protected throw
byte else import public throws
case enum instanceof return transient
catch extends int short try
char final interface static void
class finally long strictfp volatile
const float native super while
[color=red]The keywords [b]const[/b] and [b]goto[/b] are reserved, even though they are not currently used[/color]. This may allow a Java compiler to produce better error messages if these C++ keywords incorrectly appear in programs.
[color=red]While [b]true[/b] and [b]false[/b] might appear to be keywords, they are technically[b] Boolean literals[/b][/color] (§3.10.3). Similarly, [color=red]while [b]null[/b] might appear to be a keyword, it is technically the [b]null literal[/b][/color] (§3.10.7).[/quote]
transient,volatile:
[url]http://stackoverflow.com/questions/106591/do-you-ever-use-the-volatile-keyword-in-java?rq=1[/url]
[quote]When is volatile enough?
If two threads are both reading and writing to a shared variable, then using the volatile keyword for that is not enough. You need to use synchronization in that case to guarantee that the reading and writing of the variable is atomic.
But in case one thread reads and writes the value of a volatile variable, and other threads only read the variable, then the reading threads are guaranteed to see the latest value written to the volatile variable. Without making the variable volatile, this would not be guaranteed.
Performance considerations of using volatile:
Reading and writing of volatile variables causes the variable to be read or written to main memory. Reading from and writing to main memory is more expensive than accessing the CPU cache. Accessing volatile variables also prevent instruction reordering which is a normal performance enhancement technique. Thus, you should only use volatile variables when you really need to enforce visibility of variables.[/quote]