Dennis' Blog of Indiscriminate | I thought what I’d do was, I’d pretend I was one of those deaf-mutes

TAG | concurrency

Jul/08

28

網摘: Immutability in Java

很久沒 quote Java 的東東了

Part 1 on Immutability in Java:
http://jeremymanson.blogspot.com/2008/04/immutability-in-java.html

Part 2 on Immutability in Java:
http://jeremymanson.blogspot.com/2008/07/immutability-in-java-part-2.html

Part 3 on Immutability in Java – Deserialization and Reflection:
http://jeremymanson.blogspot.com/2008/07/immutability-in-java-part-3.html

 

 

重點是, final 是必需的。之前的 Javaspeciallist 的文章有有提到。final 的功用不但會限制寫入和方便 inner class 存取而已,它會影響 Just-In-Time compiler 的行為,和防止它作出過份優化而引起的錯誤。

該記著,JRE 不是一行一行執行你的 code(那只會在 debugger發生),而且在 JIT 在 SMP 的情況下會令到 bytecode 執行次序更加難以估計。該加上 final / violate 地方不要偷懶。

, Hide

  1. The Law of the Ritalin Child
  2. The Law of the Distracted Spearfisherman
  3. The Law of the Overstocked Haberdashery
  4. The Law of South African Crime
  5. The Law of the Leaked Memo
  6. The Law of the Corrupt Politician
  7. The Law of the Micromanager
  8. The Law of Greek Driving
  9. The Law of Sudden Riches
  10. The Law of the Uneaten Spinach

, , Hide

Jul/07

21

The Secrets of Concurrency

最近 Dr Heinz M. Kabutz 開始在上 http://www.javaspecialists.eu 以 Concurrency 為主題寫 article ,內容係在如何在 Java 正確地使用 Thread 和 Lock 來寫出正確 Concurrency 的 Java。

  1. The Law of the Ritalin Child
  2. The Law of the Distracted Spearfisherman
  3. The Law of the Overstocked Haberdashery
  4. The Law of South African Crime
  5. The Law of the Leaked Memo
  6. The Law of the Corrupt Politician
  7. The Law of the Micromanager
  8. The Law of Greek Driving
  9. The Law of Sudden Riches
  10. The Law of the Uneaten Spinach

十篇當中已經公開登左兩篇。而因為我係 email subscriber,收到的份 PDF slides preview 大概了解十條的主題。

點講好呢,我 strongly recommend 會用 Java 寫 Multi-thread 程式的人花兩三日仔細反復讀完它們。當中有 1/3 你會係一D比較舊的經典 Java 天書中找到,另外 1/4 就會係一D有仔細認真介紹 Java 5/6 的書本出現。而最後的,幸運的你可能從來沒有見過,也可能無法重演錯誤而把它當成 phantom,或把它當成 Java 的 bug。

  1. The Law of the Ritalin Child
    • 不要過度活躍
      唔好無視被叫停的指示
  2. The Law of the Distracted Spearfisherman
    • 唔好太花心
      KISS (Keep It Simple, Stupid)
  3. The Law of the Overstocked Haberdashery
    • 無咁大個頭唔好戴咁大頂帽
      請有計算地使用
  4. The Law of South African Crime
    • 在犯罪率高的地方,就會不自覺地犯罪
      睇書或者讀 Open 的 Source 見到人地咁寫,唔好照抄
  5. The Law of the Leaked Memo
    • 匆忙之間被遺忘了的字條
      依一條 Law 比較深,99% 的書都唔會講,但又係好重要
  6. The Law of the Corrupt Politician
    • 腐敗政客:表裏不一
      在應用某句 staement 為你做事之前,先看一看它有沒有腐敗
  7. The Law of the Micromanager
    • 要管理好最細小的事物
  8. The Law of Greek Driving
    • 小心單線道路
      Memory 的
      道路會比你所想的可能來得狹窄
  9. The Law of Sudden Riches
    • 暴發戶
      錢太多都係一個問題
  10. The Law of the Uneaten Spinach
    • 不治之症
      除了人道的安樂死或扼殺它的生存之外,別無它法

其實,.NET 有無D類似嘅特別因為係 CLR 而要留意嘅地方呢?

, Hide

Theme Design by devolux.org