首页 > 百度Java一面面经
头像
ZZZ13
编辑于 2020-08-21 14:30
+ 关注

百度Java一面面经

1.int和Integer、long和Long各种相等不相等
2.String a="abc",b="ab"+"c",c=new String("ab")+"c"; ==吗
3.这三个方法的关系,同时执行
public void f1(){
    synchronized (this){
        System.out.println("F1");
    }
}

public void f2(){
    synchronized (Integer.class){
        System.out.println("F2");
    }
}

public synchronized void f3(){
    System.out.println("F3");
}
用下面代码测试,一看就知道
class Solution   {
    public static void main(String[] args){
        Solution s = new Solution();
        new Thread(new Runnable() { @Override public void run() {
                s.f1();
            }
        }).start();

        new Thread(new Runnable() { @Override public void run() {
                s.f2();
            }
        }).start();

        new Thread(new Runnable() { @Override public void run() {
                s.f3();
            }
        }).start();
    }

   public void f1(){
        synchronized (this){
            try {
                for (int i=0;i<10;i++) {
                    System.out.println("F1");
                    Thread.sleep(100);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
   }

   public void f2(){
        synchronized (Integer.class){
            try {
                for (int i=0;i<10;i++) {
                    System.out.println("F2");
                    Thread.sleep(100);
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
   }

   public synchronized void f3(){
       try {
           for (int i=0;i<10;i++) {
               System.out.println("F3");
               Thread.sleep(100);
           }
       }catch (Exception e){
           e.printStackTrace();
       }
   }
}



4.说一下Spring
5.数据库相关:聚簇索引、非聚簇索引;性别上建索引会怎么样,能加快吗?事务特性;乐观锁,悲观锁;数据库隔离级别;MVCC;为什么limit会越往后越慢;
6.JVM
7.线程怎么新建;循环打印;
8.项目;分布式锁,数据库怎么实现
9.两个栈实现一个队列

更多模拟面试

全部评论

(1) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐