The difference between 1.static
Static variable meaning in C language
1. If it is a static local variable, it is a variable declared and defined inside the function and cannot be called outside of the function.
2. If it is a static external variable, it is declared within this file definition, cannot be used beyond the file invocation, and has been occupied memory, not be destroyed.
In the Java language, static-modified variables are the meaning of class variables.
2.volatile in C and Java
When using C for embedded programming:
In general, volatile is used in the following places: 1, the interrupt Service program modified for other programs to detect variables need to add volatile;2, multi-tasking environment to share the flag should be added volatile;3, The hardware register of the memory map is usually also marked with a volatile description, because each time it is read and write may have different meanings, in addition, these situations often need to consider the integrity of the data (the correlation of several flags read half interrupted rewrite), in 1 can be achieved by the shutdown interrupt, 2 Can prohibit task scheduling, 3 can only rely on the good design of hardware volatile to ensure that each value is taken from the main memory, to ensure the absolute correctness of the value, not from the register, the volatile modified variable is prone to accidental changes in the value of external factors in Java, Volatile is not locked so that using volatile in Java is very restrictive, so it is recommended to use a lock to decorate (synchronized), synchronized is the Java language keyword that can be used to lock objects and methods or blocks of code, When it locks a method or a block of code, at most one thread at a time executes the segment code. When two concurrent threads access the same object in the same lock synchronization code block, only one thread can be executed within a single time. The other thread must wait for the current thread to finish executing the block before it can execute the code block. However, when a thread accesses one of the lock code blocks of object, another thread can still access the non-locking code block in the object. Http://baike.baidu.com/link?url=CsUO5wFqymqI9K7I8HtNH8KUFCGRRkFXC9mErbCHAeniPlhY7R4RsA6TdoEbNyeDNgHoHYMEoYqZyfrksHgpbK
C and JAVA