呢幾日諗緊一個難題,話說有個朋友,中學識嘅。我無同佢同過班,剩係同佢一齊讀過一個星期先有兩堂嘅 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
-
睇中咗部 HTC Touch 但一直無機會買,今日就專登落灣仔買咗。部 Palm m505 都跟咗我五年半有多,都係時候退役。 HTC Touch 係厚少少 但係 size 真係好細,好吸引 放落部 palm 個舊 case, 差別好明顯 呢份,就當係送俾自己嘅生日禮物。依家,只...
-
呢幅畫點睇都似十八世紀嘅作品,點會變成不雅㗎... 點睇都係一個字:「美」 唔通,真係露一點半點,就係不雅? 名畫當不雅影視處鬧笑話 神話書封面用裸露作品 一度勸書商停賣 2007年7月19日 【明報專訊】原定在昨日書展上出售的一本著作《愛情神話》,昨日幾成「大衛像翻版」。影...
-
是日 Last Day, 要見另一個客,除咗幫佢 Troubleshooting 之餘,亦都去度別。攪咗一個朝早,到最後都係蠢事一樁,因為成村人等開飯,要飛的返公司。開完 Lunch Party, 再執多少少嘢,就先搬返屋企,順道去買餅。返到公司之後,開始瘋狂影相,有單人相,有主...
-
呢個表現都二百萬磅,下屆奧運要收支平衡都幾難,蝕梗!
-
呢幾日,將瞓覺時間推前一個鐘,做 gym 亦用嚟跑步多,結果係個人精神咗,亦開始瘦咗,即係健康咗。呢個係我兩年前嘅生活,終於返返嚟喇! 無憂嘅日子,可以維持幾耐呢?
-
Proposition 1: 基本法無所謂嘅公投,舉辦任何形式嘅公投,係違反基本法 Proposition 2: 中央政府唔承該任何形式嘅公投 Dilemma: 如果中央政府視「五區公投」為普通補選,咁即係無違反基本法 如果中央政府視「五區公投」為公投,係違反基本法,但原來佢真係...
-
多年來係 South Park 嘅 Fan. 今次將奧運嘅大場面卡通化,別有一番風味。
-
今日生日,收到幾個保險經紀嘅賀電,算係平淡嘅一日。放工之後,同事們開咗個小聚餐,舊同事亦上嚟一齊打機。大家一齊開開心心咁過一晚,係一件好事。
-
完全雞同鴨講,Demo OK, Sell 得不太好。要斷續努力。
-
字裏行間,就可以見到香港良心同民主之父嘅分別。 新聞穚 10月19日 陳方安生:恢復立法會的尊嚴和權威 雖然我身在外地,但仍密切關注香港發生的大事。我曾經是地區直選產生的立法會議員,看到10月15日行政長官宣讀施政報告過程中,某些直選議員的行為,我實在震驚。假如他們以為藉著這種不...