iamjerryyeung

Saturday, May 26, 2012

java concurrency

http://tutorials.jenkov.com/java-concurrency/nested-monitor-lockout.html

Nested Monitor Lockout vs. Deadlock

The result of nested monitor lockout and deadlock are pretty much the same: The threads involved end up blocked forever waiting for each other.
The two situations are not equal though. As explained in the text on Deadlock a deadlock occurs when two threads obtain locks in different order. Thread 1 locks A, waits for B. Thread 2 has locked B, and now waits for A. As explained in the text on Deadlock Prevention deadlocks can be avoided by always locking the locks in the same order (Lock Ordering). However, a nested monitor lockout occurs exactly by two threads taking the locks in the same order. Thread 1 locks A and B, then releases B and waits for a signal from Thread 2. Thread 2 needs both A and B to send Thread 1 the signal. So, one thread is waiting for a signal, and another for a lock to be released.
The difference is summed up here:
In deadlock, two threads are waiting for each other to release locks.

In nested monitor lockout, Thread 1 is holding a lock A, and waits
for a signal from Thread 2. Thread 2 needs the lock A to send the
signal to Thread 1.

Tuesday, April 24, 2012

postgresql

http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL

http://www.sitepoint.com/site-mysql-postgresql-1/

Sunday, April 22, 2012

hibernate profiler

http://hibernateprofiler.com/Learn

java agent instrumentation using javaassit

http://www.informit.com/guides/content.aspx?g=java&seqNum=589

to trace code using JavaAsssist

http://www.informit.com/guides/content.aspx?g=java&seqNum=585

hibernate debugging

show_sql,
format_sql
use log4j.properties, org.hibernate-> DEBUG, org.hibernate.type->FINE or use P6Spy to snoop JDBC connection

# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
 
# Root logger option
log4j.rootLogger=INFO, stdout
 
# Hibernate logging options (INFO only shows startup messages)
log4j.logger.org.hibernate=INFO
 
# Log JDBC bind parameter runtime arguments
log4j.logger.org.hibernate.type=trace
 
http://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-log4j/
 
http://www.mkyong.com/hibernate/how-to-configure-log4j-in-hibernate-project/ 

Tuesday, April 03, 2012

perm space

http://anshuiitk.blogspot.com/2010/11/excessive-full-garbage-collection.html

Thursday, January 26, 2012

internet to cisco

1. mac book connect to ethernet, then VPN
2. turn on air port
3. Use "sharing", check internet sharing with from "ethernet" to "airport"
4. run Charles, change the HTTP Proxy port to 9988
5. on iPad, go to wifi -> linksys -> Proxy, click manual, type in the ip address of air port and port of HTTP proxy defined in charles

Tuesday, December 06, 2011

http://www.javamex.com/tutorials/memory/instrumentation.shtml

classmexer to find out the size of an Java object (could be deep) using Instrumentation

Sunday, November 13, 2011

hibernate insert false

http://stackoverflow.com/questions/2468106/hibernate-update-jpa-foreign-key