Benx Blog

五月 31, 2008

Diigo Diary 05/31/2008

Filed under: Diigo Diary — benxshen @ 8:30 上午
  • tags: apache, tutorial, htaccess, howto

  • tags: no_tag

    • Q What is the difference between Class.forName() and ClassLoader.loadClass()?

      A Both methods try to dynamically locate and load a java.lang.Class object corresponding to a given class name. However, their behavior differs regarding which java.lang.ClassLoader they use for class loading and whether or not the resulting Class object is initialized.

    • Additionally, Class.forName()‘s common form initializes the loaded class. The visible effect of this is the execution of the class’s static initializers
      as well as byte code corresponding to initialization expressions of all static fields (this process occurs recursively for
      all the class’s superclasses). This differs from ClassLoader.loadClass() behavior, which delays initialization until the class is used for the first time.
    • if it is important to process all such errors at a known point in code,
      you should use a Class.forName() version that performs initialization.
  • tags: classloader, jvm, java

    • Current ClassLoader:當前類所屬的ClassLoader,在虛擬機中類之間引用,默認就是使用這個ClassLoader。另外,當你使用Class.forName(), Class.getResource()這幾個不帶ClassLoader參數的方法是,默認同樣適用當前類的ClassLoader。你可以通過方法XX.class.GetClassLoader()獲取。
    • Thread Context ClassLoader,沒一個Thread有一個相關聯繫的Context ClassLoader(由native方法建立的除外),可以通過Thread.setContextClassLoader()方法設置。如果你沒有主動設置,Thread默認集成Parent Thread的 Context ClassLoader(注意,是parent Thread 不是父類)。如果 你整個應用中都沒有對此作任何處理,那麼 所有的Thread都會以System ClassLoader作為Context ClassLoader。知道這一點很重要,因為從web服務器,java企業服務器使用一些複雜而且精巧的ClassLoader結構去實現諸如JNDI、線程池和熱部署等功能以來,這種簡單的情況越發的少見了。
    • 事實上,Context ClassLoader提供一個突破委託代理機制的後門。
  • tags: no_tag

    • Lock objects work very much like the implicit
      locks used by synchronized code.
    • As with implicit locks, only one
      thread can own a Lock object at a time.
  • tags: jdk1.5, new-features, thread

  • tags: software, freeware, download, pchome

發表迴響 »

仍無迴響。

RSS feed for comments on this post. TrackBack URI

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s

在 WordPress.com 建立免費網站或網誌.

%d 位部落客按了讚: