呢幾日諗緊一個難題,話說有個朋友,中學識嘅。我無同佢同過班,剩係同佢一齊讀過一個星期先有兩堂嘅 Computer Studies, 但係就偏偏係依家最老死嘅朋友。
我今日都問過佢,但係佢都解唔到究竟我哋點樣熟絡。我諗唯一解釋到嘅,就係緣。緣呢樣嘢好奇妙,只要時辰一到,擋都擋唔住。無嘅話,真係住响隔籬,甚至做埋同房,都唔會識到。
我呢,人緣就幾好喇,但姻緣就嘛嘛。
Search This Blog
Monday, January 31, 2005
Self-disposing Resource Pattern
A few mon, I have encountered a quite disturbing problem (see below). Until recently, I found that this problem can be solved by a interesting class, SoftReference, in Java. So, I formulated the following pattern. It's still a rough draft, but I would like to publish it first.
Name: Self-disposing Resource Pattern (Java)
Context: A is some expensive resource that may or may not be pooled. A is used to create another kind of resource, B. If A is disposed, it cannot create B anymore. However, if A is not disposed, the system may run out of memory.
Problem: Determine when to dispose A.
Solution: Java comes with SoftReference class for memory management. “An object is softly reachable if it is not strongly reachable but can be reached by traversing a soft reference.” An A instance can be registered to a resource manager to be a soft reference when it is no longer reachable by any thread. On the other hand, the resource manager can start off a thread to dequeue the SoftReference instances from a reference queue and clean up the resource properly.
Name: Self-disposing Resource Pattern (Java)
Context: A is some expensive resource that may or may not be pooled. A is used to create another kind of resource, B. If A is disposed, it cannot create B anymore. However, if A is not disposed, the system may run out of memory.
Problem: Determine when to dispose A.
Solution: Java comes with SoftReference class for memory management. “An object is softly reachable if it is not strongly reachable but can be reached by traversing a soft reference.” An A instance can be registered to a resource manager to be a soft reference when it is no longer reachable by any thread. On the other hand, the resource manager can start off a thread to dequeue the SoftReference instances from a reference queue and clean up the resource properly.
Friday, January 28, 2005
First Week of the Semester
The school has been started this Tuesday. I attended to the classes for three consecutive nights. It's so tired. Tomorrow, I need to take another one in the afternoon. I'll need to decide whether I should drop the Tuesday class. That class was very boring.
Monday, January 24, 2005
Days of Part-time Working
I haven't blogged for a long time. I am currently working as a part time. In theory, I should have more time than before and I should have more time to blog. Obviously, it's not.
I found that there are many personal stuff have to take care in the first. Like have the MP3 player fixed, applying for CEF, etc.
The second week, I got cold again. I had to take rest at home and didn't go to work out. My body get a bit slimmer. It's not good though. After I got better, I go hiking with friends and upgrading the CPU. Actually, these few weeks I was trying to get an AMD's Althon XP CPU which was out of stock. I gave up in this week and got a Sampron. Another thing I wanted to get was a Palm T3 which was again out of stock. I am considering if I should by T5 instead.
This week, I finally started trying to swim. Rocky now is my "couch" preventing me from drowning. Even just one day, I thought I had the key to swim.
Today, we went to Leo's home to play video games and having dinner together. It's a tired but enjoyable day. Rocky and I almost missed a bus when going there. However, we still miss the stop to get off the bus. Luckily, Michael and Sammi were still enjoying their lunch.
Interesting enough, we missed the bus of the back trip. We then take the MTR to get back home. When getting the last trip of the train, we missed the train again.
I found that there are many personal stuff have to take care in the first. Like have the MP3 player fixed, applying for CEF, etc.
The second week, I got cold again. I had to take rest at home and didn't go to work out. My body get a bit slimmer. It's not good though. After I got better, I go hiking with friends and upgrading the CPU. Actually, these few weeks I was trying to get an AMD's Althon XP CPU which was out of stock. I gave up in this week and got a Sampron. Another thing I wanted to get was a Palm T3 which was again out of stock. I am considering if I should by T5 instead.
This week, I finally started trying to swim. Rocky now is my "couch" preventing me from drowning. Even just one day, I thought I had the key to swim.
Today, we went to Leo's home to play video games and having dinner together. It's a tired but enjoyable day. Rocky and I almost missed a bus when going there. However, we still miss the stop to get off the bus. Luckily, Michael and Sammi were still enjoying their lunch.
Interesting enough, we missed the bus of the back trip. We then take the MTR to get back home. When getting the last trip of the train, we missed the train again.
Sunday, January 2, 2005
Summary of These Two Weeks
Xmas eve - Had a party with colleague, then friends.
Day after boxing day - BBQ with other friends, dinner with yet some other friends. It's a great day.
New year eve - tried to buy T3. However, it seems that it was totally out of stock.
Plan on 2005 - Study. Start profiling my financial status, again.
Day after boxing day - BBQ with other friends, dinner with yet some other friends. It's a great day.
New year eve - tried to buy T3. However, it seems that it was totally out of stock.
Plan on 2005 - Study. Start profiling my financial status, again.
Subscribe to:
Posts (Atom)
Popular Posts
-
前幾日,睇到呢篇文 嬲爆!電車司機哭訴,竟被斥奴隸! 今日搵返出嚟嘅時候,見到另一篇謬論,先回: 1。歐、美各國發達或不發達民主國家。出糧時,最少4 % 扣去供EI unemployment insurance 失業保險,最少3 % pension 退休金,如非管理層,最...
-
給佔中三子和泛民議員的一封公開信 (美國)尹浩鏐 我是一個旅居美國快50 年的老華僑,原本不必為香港的前途擔憂,但我又不能不擔憂,因為那裡住著600萬我的親人同胞,不能眼看著他們被少數有心人帶入死胡同而不發一聲,我人微言輕,我的話你們不一定會聴得入耳,但我若不把心裡話吐出...
-
This is the third entry of today. It's been a long time I didn't blog. I would like to keep the diary before I forgot it. OK, here y...
-
Ten days ago, it was my 26th birthday. My colleagues have throw a small party at lunch. I also got a gift from a friend of mine in the eveni...
-
香港嘅社會運動,到最後散水嘅時候,都話會將運動「遍地開花」。但之後就只會隨住時間而忘記,又或者係每年一兩次嘅集會先再講起。 真正嘅片地開花,就只可以由教育體制、宣傳著手。政府要推國民教育又或者係每晚新聞前嘅國歌,就係要愛國愛黨嘅情操遍地開花。政府只要定好政策,拎到撥款,就可以...
-
响新聞度聽到政府官員响立法會講休「恬」空間,惡夢... 正字人去咗邊?
-
咁就一個月,之前寫咗個 program 仔去做 backup facebook 嘅 content. 跟住發現咗一個功能,反正一個月可以做個月結。因為 Like 係最簡易嘅動作,就用 Like 嚟做個小分析。 呢個走勢圖入面,大家重記唔記得每個高峰點發生過乜事? 頭10...
-
如果你問我,正生搬去屋企附近有無問題,我無所謂。反而明報今日一則副刊,令我有更深切嘅反思: 共同分擔不受歡迎設施 對於有梅窩人不滿偏偏選了他們的社區,陳健民說,社會有多類型的設施需要大家承擔,只要不是過於集中一個地區,就有道德責任接受,就算富裕如數碼港 的富豪區,也有此責任。美國...
-
Sad but true... Confirmed: Microsoft Says It Will Open Source VB 6 Re:And we care why? (Score:4, Funny) by fragfoo (2018548) writes: on Th...
-
想當年响學校遇到一個非常之伯父嘅老師,見佢第一眼已經覺得佢好惡,求神拜佛希望佢唔好教我。當然,天主教學校對神神佛佛一慨不理,中三嗰年,就係佢教 Physics. 佢係湯 Sir, 湯應祥老師,係眾學生口中嘅蘋果佬。 蘋果佬嘅來源有兩種說法,有一說係似前學校門口有檔生果攤,學生...