My Pages

Friday, January 07, 2011

<转载>帮你是出于交情,不帮你是应该

A不喜欢吃鸡蛋,每次发了鸡蛋都给B吃。刚开始B很感谢,久而久之便习惯了。习惯了,便理所当然了。于是,直到有一天,A将鸡蛋给了C,B就不爽了。她忘记了这个鸡蛋本来就是A的,A想给谁都可以。为此,她们大吵一架,从此绝交。

有一年,很热的夏天,一队人出去漂流。

女孩的拖鞋在玩水的时候,把拖鞋掉下去了,沉底了。到岸边的时候,全是晒的很烫的鹅卵石,他们要走很长的一段路。于是,女孩儿就向别人寻求帮忙,可是谁都只有一双拖鞋。女孩心里很不爽,因为她习惯了向别人求助,而只要撒娇就会得到满意地答复。可是这次却没有。她忽然觉得这些人都不好,都见死不救。

后来,有一个男孩将自己的拖鞋给了她,然后自己赤脚在那晒得滚烫的鹅卵石上走了很久的路。还自嘲说是铁板烧。女孩表示感谢,男孩说,你要记住,没有谁是必须要帮你的。帮你是出于交情,不帮你是应该。女孩记住了男孩的话,自此以后学会了对施以援手的人铭记在心,并给以更大的回报。

很多时候,我们总是希望得到别人的好。

一开始,感激不尽。可是久了,便是习惯了。习惯了一个人对你的好,便认为是理所应当的。有一天不对你好了,你便觉得怨怼。其实,不是别人不好了,而是我们的要求变多了。习惯了得到,便忘记了感恩。

Thursday, January 06, 2011

<转载>Stuck Thread

A stuck thread means a thread is blocked and can't return to the thread pool smoothly in a given period of time. When an application thread is blocked unintentionally, it means it can't quickly complete its dispatch and be reused. In most of production situations, the root cause of these stuck threads is also the root cause of bad system performance because it interferes with regular task execution. [It's also a performance issue for producers and healthy consumers. < 1 ] (request frequency) < (healthy thread count for request execution/average measured request execution time per healthy thread.]

Blocking without specifying a network connect or read timeout is the most frequent reason we have seen. When we don't manually configure a timeout for each method call involving networking, it will have a potential blocking behavior by the underlying physical socket read/connect characteristic. While waiting infinitely for the response from the other side, the native OS networking layer probably throws an I/O exception. By default this behavior takes an unexpectedly long time (e.g., 240 seconds). Modern distributed systems need to factor in this situation (especially, Web Services invocations). Though we may set timeouts for well-known protocols via some system properties (e.g., sun.net.client.defaultConnectTimeout and sun.net.client.defaultReadTimeout), the newer version of JDK might provide a generic mechanism to explicitly configure each default timeout value for those whose methods call socket connect/read as a security policy file. For example, com.sun.jndi.ldap.read.timeout (http://java.sun.com/docs/books/tutorial/jndi/newstuff/readtimeout.html) wasn't available prior to JDK 6.0 for LDAP service provider read timeout. Otherwise, when the problematic code isn't under the control of end users, it usually needs to restart the application to temporarily reset the abnormal phenomenon propagated from the other side. In addition, we should take into account whether the service we called is idempotent while analyzing this kind of issue in the design phase because we don't know whether the service at the other end keeps executing when the thread has ended its invocation after a timeout (see Figure 4).

The unexpectedly long execution time of a SQL statement is a common condition that causes a stuck thread. In the thread dump we collected, we can see that the stuck thread was running a network socket read for a long time without changes and the thread's stack trace contains many JDBC driver classes. Under these conditions, we can also check the status of the database it connected with and set the query timeout for all application code using a JDBC statement setQueryTimeout method. (Most JDBC drivers support this feature but we'd have to read the JDBC driver's release note first.) According to the different nature of every SQL query, it would be better to segregate the programs that have a longer execution time in another thread pool and tune the database table with indices for faster access. We would also need to check whether the JDBC driver is certified with the connected database. A sub-issue is the accessed table locked by other processes so the threads for the JDBC query couldn't continue because of table locking.

Resource contention is an issue that's hard to find if we don't get the entire thread dump to analyze. Basically, it's an issue of producers and consumers. Any limited resources on the system (JDBC connections, socket connections, etc.) will impact this issue. The best thing to do is look at the thread dump, get the stuck thread name from the log, and find the bottleneck that's causing the stuck thread.

File descriptor leaking is an issue that causes this phenomenon (Note that a Unix socket implementation requires a file descriptor). So the JVM should have enough file descriptor numbers to host our applications. Generally, we can adjust the open file limit with the Unix shell 'ulimit' command for the current shell. And we can list the open files with the public domain 'lsof' tool. It's intensely interesting that many developers don't explicitly use the 'close()' method in the final block when an object inherently provides a 'close()' method and want JVM to release these unclosed objects when garbage is collected. We should keep firmly in mind that that act is bad without closing the system resource after use. A special case is when the socket connections in the application don't close properly while still being underdeployed and then the application begins to throw an IOException with a 'Too many open files' message after repeated application redeployment.

Quotes from :
http://java.sys-con.com/node/358060 Looking Inside Stuck Thread

Sunday, January 02, 2011

The Curve - Bubba Gump

That was a few nights after Xmas. Darling said wish to bring me to a better place rather than having dinner around office. "A secret place for us to dinner" - darling said so. Although he had no idea where to eat. We stopped at this restaurant "Bubba Gump". This also the place that we celebrated his birthday for his 25th yrs old.

A good place for prawn lovers. =) Whole menu full with prawn and shrimp. But still provides some others food like fish and chips, chicken chop and bla bla bla. As for a person who doesn't love seafood, i chose fish and chips. =D

The logo for this restaurant, a smiling shrimp. But it doesnt look that cute. haha.


A signboard on the table. "Run Forrest Run", it tells the waiters u do not need their serving at that moment.


"Stop Forrest Stop" - It's time for serve us now. They are very sensitive to this sign. Do not simply flip to this sign unless you reali wish to. haha.

Monday, December 27, 2010

无题

有的上网了,又了iPad了。

为什么我好像多了很多时间自己和自己说话呢?

他玩iPad,我玩电脑。

我们真的开心吗?

破纪录,Go Go Go!

今天破了自己一直以来的记录哦!

以前曾经爬过13楼,所以一直引以为荣。今天不同了!我破自己的纪录!爬了40楼!哈哈。虽然爬的过程有点晕晕的。不过,还算不错啦。
她们说要每天做运动哦。嗯。。不知道能持续多久呢?哈哈!

Sunday, December 26, 2010

大难来临时,你会牵住我的手吗?


为什么人们总是喜欢问对方类似的问题?

又有多少个人曾经问过自己这个问题?在大难来临时,我会放手吗?在问对方的时候,我们可曾想过自己?我曾问过我自己这个问题,答案是我不知道。因为我还没有遇过类似的事情。但,人总是爱听美丽的谎言的吧。我也很想听那些美丽的谎言,我也很想听他承诺的天长地久,只死不渝。哈哈。

不过,有一点我很可以肯定地对他说(对你说),大难来临的时候,我不要你牵住我的手。我不要你和我一起承担什么,我只要和你一起分享什么。我不要我爱的人和我一起承受任何苦难。我只要我爱的人每天都开开心心,幸福快乐,那就够了。

不过,我倒是不介意和你一起分担你的苦难。哈哈。反正最终的目的,我只要你快乐。你的快乐,就是我的快乐。我的痛苦,不是你的痛苦。你不要那么傻和我一起苦。一段感情里,有一个傻子就够了。

总而言之,在我大难来临时,请不要捉住我的手,我会自己走。。

iPad + Internet

有得上网的iPad, 等于有了一切,也等于我会被忽略。。

Saturday, December 25, 2010

祝福你。


偷偷看了渔夫的blog,真的是偷偷的。


原来去年的圣诞节我们在sunway bbq哦。我真的不记得了。为什么啊?为什么和他的记忆那么快就不怎么记得了?自从block了他的msn开始,就好像和他没有什么瓜葛了。虽然,我其实还有些东西留在他那里。


我其实也还蛮关心他的吧。希望知道他过的好不好。不然,我也不会一直去看他的blog吧。他也蛮厉害的哦。还用 location tracking 。记录什么地区的人曾到过他的 blog。他会不会期待我去看呢?还是其实他早就知道我看了?


其实我也不是存心要做到这么绝的。但,当回普通朋友真的行的通吗?当我开始想和他象普通朋友一样时,他又会得寸进尺。把我又逼得退后几步了。既然我们没有办法做回普通朋友,那就不要勉强了吧。



我知道他还没有从以前里走出来。我以为那么短的时间,伤痛应该不会那么深的。但看起来我好像错了。他还是没有办法放下。对不起,我太自私了。我其实不奢望他原谅我。但我还是衷心地祝福他。。。

圣诞节快乐!

圣诞节快乐!

今年的圣诞节还过得蛮快乐的!好像比去年快乐哦。虽然我已经不记得去年是怎么过了。

和同事+朋友聚餐,再去酒吧喝酒,看起来很颓废哦!不过,空虚的我们,应该也算了在其中啊。哈哈。而且,今年的他虽然已经和去年的不一样了。但,我其实比较enjoy和现在的他哦。我的darling。哈哈。和他在一起我真的很开心。虽然他最后喝到醉倒了,还要我送他回家。好像很逊哦。呵呵。不过,在我心中,他还是最棒的。

新的一年就要到了,希望明年能过顺顺利利,大吉大利^^