二\Session和 appliction的区别是什么?有什么区别?

解决方案 »

  1.   

    简单的理解就是
    Application 是共用的
    Session 是请求独享的
      

  2.   

    编译都通不过,没有导入包,大小写错误,for语句错等等
      

  3.   

    thread不需要导入包的,不过一看就知道public应该全部小写的,而且,for里面应该用;号
    得出的结论应该按照顺序把Earth,moon分别打出来
      

  4.   

    结果:
    Earth
    Moon
    Earth
    Moon
    Earth
    Moon
    Earth
    Moon
      

  5.   

    试过,结果和 kaiser_800(绿色兵团)一样,不过不是很理解,高手解释下。
      

  6.   

    结果:
    Earth
    Moon
    Earth
    Moon
    Earth
    Moon
    Earth
    Moon
    请给你说明,解释一下
      

  7.   

    为什么得出的结论应该按照顺序把Earth,moon分别打出来???
    说明一下?
      

  8.   

    第一个Earth,最后一个Moon,中间的次序不一定,但是Earth,Moon总数都是4。
      

  9.   

    谁写的滥程序?大小写都不注意,我来修改一下。
    package test;public class Test
        extends Object
        implements Runnable {
      String s1 = "Earth";
      String s2 = "Moon";
      public void run() {
        synchronized (s1) {
          for (int i = 0; i < 2; i++) {
            s1.concat("to Moon");
            System.out.println(s1);
            s2.concat("to Earth");
            System.out.println(s2);
          }
        }
      }  public static void main(String[] args) {
        Test t = new Test();
        new Thread(t).start();
        new Thread(t).start();
      }
    }输出结果:
    EarthMoonEarthMoonEarthMoonEarthMoon
      

  10.   

    解释一下new Thread(t).start();执行,调用for循环输出EarthMoonEarthMoonEarth
    ,然后出因为i=2,出for循环,new Thread(t).start();再执行,此时i为局部变量,i又重新为0,在执行两遍for循环输出,
    MoonEarthMoonEarth
      

  11.   

    s1.concat("to Moon");
    s2.concat("to Earth");
    这两句话都没有起作用吗?
      

  12.   

    s1.concat("to Moon");
    s2.concat("to Earth");
    这两句话都没有起作用吗?同感
      

  13.   

    s1.concat("to Moon");
    s2.concat("to Earth");
    ===========================
    请教各位大哥这是什么意识?
    谢了
      

  14.   

    jdk1.5 结果如下:
    ---------------------------------------------------
    Earth to moon 
    Moon to earth 
    Earth to moon to moon 
    Moon to earth to earth 
    Earth to moon to moon to moon 
    Moon to earth to earth to earth 
    Earth to moon to moon to moon to moon 
    Moon to earth to earth to earth to earth ---------------------------------------------------
    public class Thread1 implements Runnable {
    String s1 = "Earth "; String s2 = "Moon "; public void run() {
    synchronized (s1) {
    for (int i = 0; i < 2; i++) {
    s1 = s1.concat("to moon ");
    System.out.println(s1);
    s2 = s2.concat("to earth ");
    System.out.println(s2);
    }
    }
    } public static void main(String[] args) {
    Thread1 t = new Thread1();
    new Thread(t).start();
    new Thread(t).start();
    }
    }
      

  15.   

    concat方法是只返回相加后的值的,并不改两个变母串的值。
      

  16.   

    public String concat(String str)这是方法说明也就是,这个方法不改变传进来的参数除非你写成 s1 = s1.concat("to moon ");也就是重新赋值
      

  17.   

    s1.concat("to Moon")表示把to Moon加到s1的尾部,但是不改变s1的值
      

  18.   

    jdk1.4和jdk1.5运行的差别怎么大呀!
    不过在1.4上,好像结果说不通呀!1.5上的结果还可以理解!
      

  19.   

    这题跟线程没什么太大的关系,主要考的应该是concat的连接用法
      

  20.   

    String 是不变的 所以s1.concat("****")  s2.concat("****") 都是行同虚设 对象在被创建时便被废弃了    
    至于输出结果 我认为中间部分的moon,earth都是无规律的输出,因为“一个线程以某种顺序启动并不意味着它们将按照该顺序执行”.对于任何一组启动的线程来说,调度程序不保证其顺序.这个面试题和SCJP的题很像啊!
      

  21.   

    如果是 s1=s1.concat("****")  s2=s2.concat("****") 那么结果就不一样了 原先的对象将被丢弃.
      

  22.   

    jdk1.4的结果如下Earth to moon
    Moon to earth
    Earth to moon to moon
    Moon to earth to earth
    Earth to moon to moon to moon
    Moon to earth to earth to earth
    Earth to moon to moon to moon to moon
    Moon to earth to earth to earth to earth
      

  23.   

    jdk1.4里,定义一个StringBuffer就可以打印出jdk1.5的情况了