The interview in Tencent is scheduled at 7pm, and the video interview in Tencent conference is scheduled. I received the interview invitation on Wednesday, and the interviewer added wechat contact to set the time. It was initially scheduled for Thursday, but was later changed to Friday because the interviewer had something to do. The interviewer communicated very politely.

I also had some problems in this interview. I did not debug my computer well, so WHEN it came to how to write code during the interview, I knew that I needed to check the algorithm code. But maybe the interviewer doesn’t want to bother with it either.

1, Self introduction,

I introduce myself in accordance with the work experience and the reason for leaving the job, the technology stack mastered, the interest of the work of three aspects. Here, the interviewer asked me where my second job would be, and truthfully said outsourced.

What is the difference between String, StringBuffer and StringBuilder?

Here I introduce the String final feature, and then say that StringBuffer is thread safe, String, StringBuilder is not thread safe.

Java’s memory model

This issue has been reviewed previously in terms of main memory and the working memory of threads, as well as interactions between main memory and working memory, such as Read, Write, Load, Store….. To implement the interaction between main memory and working memory, volatile memory barriers are also mentioned here.

4. What do you know about Synchronized, CAS and volatile? What’s the general description?

First of all, CAS is implemented through the Unsafe class. The compareAndSet method in the Unsafe class provides THE CAS feature, and it’s a form of optimistic locking that implements changes by comparing and exchanging data. It’s also thread-safe, but thread-safe has performance problems.

Synchronized explained that the underlying implementation is implemented by the monitor in the object, and that the object is locked by the Markword in the object header, each time the markword’s object flag is set to lock and unlock. Synchronized can also be used in methods and code blocks, using monitorenter and monitorexit for locking and releasing processes in methods and ACC_SYNCHRONIZED for locking flags in code blocks. Synchronized is also a reentrant lock, that is, when a thread acquired the lock, when it acquired the lock again, it only needs to determine whether the current lock thread in Markword is the current thread, and it does not need to carry out the lock process. The issue of synchronized lock escalation is also mentioned here. Talking about the upgrade from lightweight lock to heavyweight lock, bias lock is forgotten here. (supplement: first, biased locking, biased locking in the object is through markword, a symbol of if a thread to acquire the lock, is stored in the markword the thread id, when a thread is once again the object operation, threads will judge to whether the current thread, if you don’t need to be locked. Since lightweight locks, lock is a lightweight, so can’t thread blocking, so synchronized implementation lightweight lock is done by the idea of optimistic locking, if a thread does not lock, won’t make thread block, will only make thread spin operation, if other threads to release the lock, then spin thread can get locked, However, you can’t keep spinning the thread all the time, because it consumes CPU resources all the time, so if the thread does not spin ten times to acquire the lock, the lightweight lock will be upgraded to the heavyweight lock.

The visibility aspect is data invalidation. If one thread operates on a shared variable, the shared variable becomes inoperative in the working memory of the other thread and needs to be retrieved from main memory. Forbade reordering is discussed in terms of memory barriers, load and store operations, but not in terms of details. (I forgot!)

5. Synchronized lock optimization

Here said the lock upgrade process, specific optimization bias lock, spin lock, lightweight lock, heavyweight lock forgot! At that time did not say

6. What is the difference between hashMap, hashTable, and concurrentHashMap?

HashMap is not thread safe. HashTable and concurrentHashMap are thread safe. HashMap is also thread safe. To avoid the problem of rehash, determine whether to perform rehash based on the length -1 and hashcode after capacity expansion. HashTable says that thread safety is achieved by synchronized, and concurrentHashMap says that thread safety is achieved by locking a bucket.

7. JVM garbage collector

In the garbage collector I said Serial collector, in the form of stop the world, you need to stop other work until the garbage collection is finished. This is done through the mark-clear algorithm.

The ParNew collector, which supports multithreading, is implemented through the replication algorithm.

The CMS collector, the default collector for the Hotspot virtual machine, is implemented using a generational collection algorithm.

8. Redis skip list? How does it work?

Redis jump table here did I say that by your own understanding, I will jump table as a whole building, the first building and subsequent made a point to the building, which is the third to the second tower, the fourth floor to the third building and so on, up to 32 layers, and the data is ascending in the jump table, so when the query number 3, A pointer from the first building to the third building can get a 3 without traversing. Or binary search, to avoid the case where the time complexity of the binary tree becomes O(n).

9. Are you familiar with computer networks? What is the difference between TCP and UDP?

So TCP is connection-oriented, UDP is not connection-oriented, and TCP is a reliable transport, UDP is not a reliable transport.

10. How does TCP ensure reliable transmission?

This question doesn’t answer very well on its own, from congestion control, sliding Windows, timeout retransmission, waiting for confirmation mechanisms. Other memories are not very clear didn’t say.

11. Do you understand TCP sticky packets? Under the said

Did not understand how, follow-up I can learn next!

12. How does LRU work?

The LRU get, PUT method introduced the process.

How to design the data structure of LRU?

I forgot. I was so nervous.

14. Tell me about your project? What exactly did you do, in terms of details?

From the project, and then what did you do? How does this work?

Said the project use of technology stack, and the architecture of the project, and finally said their own do the specific implementation of the function, I feel that writing here is particularly messy.

Do you have anything to ask me?

I: excuse me, what business does the company do?

Interviewer: XXXXX

Me: Through the interview, what technical aspects do you think I need to improve?

Interviewer: He said that I was not skilled in computer network and would learn more later, that I did not have a thorough understanding of LRU, and that I did not do anything particularly deep in the project and needed to deepen.

The whole interview market 37 minutes, I already know the interview is not good, because the interview ended early before the code test. On the one hand, I am not strong enough to master; on the other hand, I am too nervous. I will adjust later. I am still very grateful for this opportunity to accept an interview.

The next day, I received a text message that I failed the interview, but it was nothing. If I continued to work hard, I still lacked too much, which was also an experience. Follow up to continue refueling!

The interviewer was very nice. First of all, he was very polite, and he gave suggestions that need to be strengthened in the follow-up. This is very grateful, but I can only say that my ability is not enough, there is no frustration or disappointment. Confidence is still some, continue to work hard!