Lv 5
asked in 電腦與網際網路程式設計 · 1 decade ago

java編譯時出現的錯?

Note: loing.java uses or overrides a deprecated API.Note: Recompile with -Xlint:deprecation for details.編譯完會產生.class程式一樣會執行請問這二段是幹嘛?

2 Answers

Rating
  • ?
    Lv 6
    1 decade ago
    Favorite Answer

    您用了以前的一個API,具體的說就是您用了某個方法,該方法以前可以用,但新的版本中已不建議使用(deprecated),您可以在編譯時:javac -Xlint:deprecation YourSource.java如此可以知道哪個方法已不建議使用,再查看一下最新的線上API,看看它建議您改用哪一個方法。。。例如Thread的stop()就不建議您再用,API上是這麼寫的: 

    void

    stop()

              Deprecated. This method is inherently unsafe. Stopping a thread with

    Thread.stop causes it to unlock all of the monitors that it

    has locked (as a natural consequence of the unchecked

    ThreadDeath exception propagating up the stack). If

    any of the objects previously protected by these monitors were in

    an inconsistent state, the damaged objects become visible to

    other threads, potentially resulting in arbitrary behavior. Many

    uses of stop should be replaced by code that simply

    modifies some variable to indicate that the target thread should

    stop running. The target thread should check this variable

    regularly, and return from its run method in an orderly fashion

    if the variable indicates that it is to stop running. If the

    target thread waits for long periods (on a condition variable,

    for example), the interrupt method should be used to

    interrupt the wait.

    For more information, see

    Why

    are Thread.stop, Thread.suspend and Thread.resume Deprecated?.

  • Anonymous
    5 years ago

    【亞洲36588合法彩券公司直營 官網: A36588.NET 】

    【 最新活動→迎接新會員,首存狂送20% 】

    【運動→電子→對戰→現場→彩球 】

    【免費服務 →電影區、討論區、KTV歡唱、運動轉播、即時比分、24H客服 】

    【亞洲36588合法彩券公司直營 官網: A36588.NET 】

Still have questions? Get your answers by asking now.