Ali Bixuan: Next to test your Java programming skills

Part compiled prepare more systematic written in the Java programming advanced the idea of ​​the latter, if only to see the inside of words, many students will feel everything, but I really do not think many people really understand is, it is a simple thought Some topics of interest to students can cut to the chase, see how their Java programming level.

Too lazy to do a small program, so we will get back to you directly answer it, I will come down one by one comment, under the Friendly reminder, some problems a little pit.

  1. Server-based BIO realized, when established 100 connections, how many threads there? If the NIO-based, it will be how many threads? why?
  2. In general, based on the Server side NIO realized how many threads to handle IO event will be used, and why?
  3. A typical client clusters -> this structure LB-> server cluster, such as a client using connection pooling, long way connection, what do you think of this design problem may occur? If the client uses a single long way connected to it? If you have questions, you should think how to solve?
  4. cglib and Java dynamic proxy comparison, specifically what is the difference?
  5. Based upon Netty achieve FrameDecoder, the performance of both tags below what would be different?

The first

private void callDecode(...) {

   List<Object> results = new ArrayList<Object>();
   while (cumulation.readable()) {
         int oldReaderIndex = cumulation.readerIndex();
         Object frame = decode(context, channel, cumulation);
         if (frame == null) {
              if (oldReaderIndex == cumulation.readerIndex())
                    break;
              else
                   continue;
        }
       else if (oldReaderIndex == cumulation.readerIndex()) {
              throw new IllegalStateException( ".....");
        }
        results.add(frame);
 }
 if(results.size() > 0)
     fireMessageReceived(context, remoteAddress, results);

}复制代码

The second

private void callDecode(...) {

   int oldReaderIndex = cumulation.readerIndex();
   Object frame = decode(context, channel, cumulation);
   if (frame != null)
          fireMessageReceived(context, remoteAddress, frame);

}复制代码
  1. Executors.newCachedThreadPool create a thread pool, it is possible to produce in the course of running the risk?
  2. new ThreadPoolExecutor (10,100,10, TimeUnit.MILLISECONDS, new LinkedBlockingQueue (10)); this time to create a thread pool, when already there are 10 tasks are running, the first 11 tasks submitted to this thread pool to perform what would happen ,why?
  3. Implement a custom role ThreadFactory usually?
  4. In addition to using Object.wait and Object.notifyAll to achieve interaction between threads, but what you will be used to achieve?
  5. Why ConcurrentHashMap can be more efficient in the case of high concurrency than HashMap?
  6. AtomicInteger, AtomicBoolean reason for these classes at high concurrency efficient common reason?
  7. Please use the Queue reasonable to achieve a highly concurrent production / consumption scenario, some code snippets to the core.
  8. Please allow 10 tasks simultaneously achieve concurrent start, give some code snippets.
  9. Java programs run in stages, you can use the command-line tool to view what some startup current parameter values ​​of Java programs, such as Heap Size and so on.
  10. What command-line tool to view the status of GC Java programs running, please write specific command line format.
  11. What tools can be tracked in the case of a Java program running time of a method of execution, request parameters and other information, and please explain the principles of the tool under implementation.
  12. When a Java program receives a request for a long time I did not respond, then usually you will how to troubleshoot this problem?
  13. Java process suddenly disappear, you will how to troubleshoot this problem?
  14. The following code thinking, you think you may run the risk arises is how to improve?
List getUsers(String[] userIds){

   // 从数据库查找符合userIds的user记录
  //  将返回的记录组装为User对象,放入List并返回

}复制代码
  1. The following two codes, what is the difference in run time? why?

The first

private static final boolean isLoggerDebugEnabled = log.isDebugEnabled();
public void xx(User user){

 if(isLoggerDebugEnabled){
      log.debug("enter xx method, user id is: " + user.getId());
 }

}复制代码

The second

public void xx(User user){

 log.debug("enter xx method, user id is: " + user.getId());

}复制代码
  1. Why Java programs usually just the start of the execution will be slower, but the process will be faster after some requests, AOT can bring any help?
  2. Parallel GC, CMS GC, ZGC, Azul Pauseless GC main difference is? The rationale behind also simply described under?
  3. Please write a program be allowed to appear at runtime to trigger five times ygc, then three times fgc, then three times ygc, then once fgc, please give the code as well as startup parameters.
  4. The main difference of Coroutine Go and Java threading mechanism? If the Java language to achieve transparent Coroutine, do you think the main difficulty is?


Author: Bixuan  

Description link

This article comes from Yunqi community partners " HelloJava ", For reprint please contact the original author.


Guess you like

Origin juejin.im/post/5d5518eaf265da03e4675912