Thursday, June 7, 2012

GIST NOTES 23 - Tidbits

GIST NOTES 23 - Tidbits


*EventListener is in java.util package and it is the same listener implemented by all swing components
*EventListener is a marker interface, but why?
*RandomAccess is a marker interface, just to let others know that they can alter their behavior to provide good performance
*Collections.sort() uses Arrays.sort() internally
*Collections class is not class-wide generics class; generics usage is localized to its static methods (makes sense, because it is a util class after all)
*the class Class is genericfied as well

*Annotations
-not part of the program
-info for compiler(detect errors and suppress warnings)
-compile time and deployment time processing(tools that process annotations)
-runtime processing(sometimes available at runtime)

*infinite loops in initializer blocks(static and non-static) causes compiler error "unreachable statement" pointing the member variables

* while(true);
while(true){}
while(false);
while(false){}
for(;;);
for(;;){}

#all of the above statements cause compiler error with 'unreachable statement' when placed in initializer blocks

* Another important feature of JWS(Java Web Start) is its ability to run your application in a sandbox - a restricted container based on Java security architecture. But, unlike an applet, your application can gain access to local system resources like the filesystem, printer and system clipboard using the JNLP API even if it comes from an untrusted environment, after prompting the user for confirmation.

* in java, while reading html document streams from internet, they end with "\\\\L" token delimiter.

* Desktop Applications are commonly known as rich clients
* A thin clinet is a web client or a simple front end
* Rich client is any client with much more of logic, user interface and interactivity than any web client

* Java 5 brings ConcurrentHashMap, in which only a part of the Map is locked, such that many threads can access different parts simultaneously. This optimization is possible, since HashMap stores their data in buckets. This optimization is known as lock striping.

*Lock and ReentrantLock

Why create a new locking mechanism that is so similar to intrinsic locking ?Intrinsic locking works fine in most situations but has some functional limitations   it is not possible to interrupt a thread waiting to acquire a lock, or to attempt to acquire a lock without being willing to wait for it forever. Intrinsic locks also must be released in the same block of code in which  they  are  acquired;  this  simplifies  coding and  interacts  nicely  with  exception handling,  but makes non block structured  locking  disciplines  impossible. None  of  these  are  reasons  to  abandon  synchronized, but  in some  cases  a more flexible locking mechanism offers better liveness or performance.

*ReentrantLock  requires  that  the Lock  be  held  when  calling signal  or  signalAll,  but  Lock  implementations  are  permitted  to construct Conditions that do not have this requirement.

*AQS  is  a  framework  for  building  locks  and  synchronizers: Abstract-QueuedSynchronizer (AQS)

*AbstractQueuedSynchronizer uses Template method pattern to let subclasses define new locking mechanisms; try**() methods in AQS are hooks left for subclasses to implement

*SerialVersionUID of all enums is 0L

* "java -X" displays non-standard command line options
* The -X options are non-standard and subject to change without notice.
* -XX option is used to set gc related params

*posix (portable operating system interface) threads do not have reentrancy(lock is issued on per invocation basis) whereas java default locks are issued on per thread basis

* Forest - group of trees with no connection between them (Data Structures); removing root node of a tree results in a forest (due to the disjoint subtrees)

*The distinctions between a binary tree and a tree should be analyzed. First of all there is no tree having zero nodes, but there is an empty binary tree.

*The first is a skewed tree, skewed to the left and there is a corresponding one which skews to the right. All nodes of the binary tree are on the left side (or all on right side) in a slanting straight line.

*Complete binary tree - all nodes have either 2 children or no children

*A Complete Binary Tree can be stored in an array and easy to find parent and children of any node with given node index in the array

..... | PARENT | <-----i/2----> | NODE | <-----i----> | CHILD1 | CHILD2 | .....

where i/2 and i are the distances and i is the index of NODE in the array; this is because at every level no.of nodes double;

PARENT -> i/2
LEFTCHILD -> 2i
RIGHTCHILD -> 2i+1

*XPCOM (Cross Platform Component Object Model)
*WPA/WPA2 - WiFi Protected Access (new system)
*WEA - Wired Equivalent Privacy (old system)
*WiFi - Wireless Fidelity (came from HiFi - High Fidelity in audio equipment classification)
*Temporal Key Integrity Protocol (TKIP), was adopted for WPA
*WPA2 uses AES
*<% %> is used to place java code in jsp file
*<%=value%> is used to print the value of java variable 'value' in html from jsp
*I18N - internationlization(18 signifies no.of letters between I and N)
*L10N - localization(10 letters between L and N)

No comments:

Post a Comment