Remember once Alibaba side experience

Received last week in a pull hook on ants gold dress big brother to my resume, I was very surprised to find I actually have ants gold dress, then gave imagined.

Flattered Yeah, I know their level of how far the gap with Ali, had previously been useless courage to vote, I am afraid to even try. This actually take the initiative to come, at the time to think, so do Ali lack of people it? Or just to complete some KPI, of course, I have this idea more naive.

I did not expect the next day actually received the Alibaba e-mail invitation to the interview, which comes to the first interview will be conducted in 10 working days.

Anyway, since the interview here, try it. One can face this level of technology companies to see their true gap, but also a Sanshengyouxing. From this time departure also fill up the JVM, based on what data structure algorithms, as well as some of the high frequency of Java basic problems.

8:25 Monday night received a phone ant brother came, and sure enough, just like the legendary, still working. I was very surprised, I did not expect a phone interview, because the message did not mention, back in retrospect, looks like one side is basically a phone interview, second interview some friends also face electricity.

Entered, the following is the entire contents. Some inconsistencies order, I follow the modules to finishing.

Self introduction

Self-introduction to first introduce how old, how long have graduated, did something, to do what recent, good part of it and so on.

Said here about the content of self-introduction truthfully say like, do not be too exaggerated, the content of self-introduction suggest that you prepared in advance, do not say where the time think of where it comes.

Thread part

1, multi-threaded implementation of what?

This topic is basically one side when it comes across, inheritance Thread class that implements Runnable interface, the last call is the start () method to start a thread.

There is also a knowledge point is start () () method of difference and contact with the run.

Direct call start () method, when a thread is ready (to run) the state, but did not really run. After the CPU time slice but get started execution run () method, run () method which is our thread body.

We run directly run () method, which is actually a common method invocation, executed in the main thread, is not open multi-threaded .

2, describes some cases thread deadlock?

This problem usually come into contact with the project, virtually no how, but I have been part of the understanding. The answer is: when two threads to hold its own lock, but also to hold the lock held by the other side, due to someone else's lock has been holding each other, resulting in another case waiting for each other to release the lock. The answer was more one-sided, and some type of deadlock did not answer them, directly behind the tests, the interviewer said it does not matter.

When ready to suggest that you can say to this question deadlock condition occurs, the phenomenon of the solution and so on. And then coupled with some examples described in the interview process, the interviewer mentioned that according to the scene instance we usually encounter deadlock problem is.

It can be found at the following two questions deadlock scenario:

1, three three chopsticks: Everyone needs to get two chopsticks around to start eating

2, bank transfer issue: Thread A transfer from account X to account Y, Y thread B to transfer money from account to account X, then a deadlock occurs.

3, the project has not been used thread pool? How to use?

We answered some items inside the data interface needs to assemble multiple service encapsulation, and then return. That which we can use multiple threads to pull data in parallel, reducing the response time of the interface.

The interviewer said: "ok, then you have not read the thread pool source inside it, which has several thread pool??"

Source Here I hesitated, I said not familiar, then I said several types of thread pool newSingleThreadExecutor , newFixedThreadPool , newCachedThreadPool but also missing a newScheduledThreadPool thought up.

4, the principle of the thread pool is what? Parameters are the underlying method What does it mean?

Answer this question, I was stuck. I know these are the bottom of the call ThreadPoolExecutor , but I did not think of the name of life and death, this time to remind the interviewer for a moment, then said it does not matter.

Then he asked: "Do you know what his parameters have it all ... What do you mean??"

My answer is the number of threads and thread survival time, the other did not say come. The interviewer then said: "Never mind."

Add: the underlying thread pool is achieved by ThreadPoolExecutor.

  1. public ThreadPoolExecutor( int corePoolSize, 

  2. int maximumPoolSize, 

  3. long keepAliveTime, 

  4. TimeUnit unit,

  5. BlockingQueue<Runnable> workQueue, 

  6. ThreadFactory threadFactory, 

  7. RejectedExecutionHandler handler)

Meaning several parameters are as follows:

  • corePoolSize: The minimum number of threads in the thread pool

  • maximumPoolSize: The maximum number of threads in the thread pool, thread when it will exceed the maximum use RejectedExecutionHandler

  • keepAliveTime: thread maximum survival time, more than this time will be recovered

  • unit: unit maximum survival time of thread

  • workQueue: asynchronous task execution queue cache needs

  • threadFactory: Create a thread factory

  • handler: deny policy, means that when workQueue is full, and the number of threads in the pool reaches maximumPoolSize, the thread pool policy to refuse to take the time to add a new task. DiscardPolicy: abandon the current task, DiscardOldestPolicy: throw away the oldest, CallerRunsPolicy: to perform this task by a thread submit jobs to the thread pool, AbortPolicy: RejectedExecutionException throws an exception.

Asked here, I was really very limited answer, the interviewer did not ask then fine, or said: "Never mind."

If you are here to answer them, then I think you need to know is that these types of thread pool what type of circumstances in which, and to pay attention to what the problem is, very likely the interviewer will continue to root out .

Here is not the answer, I believe you go to search about, the experience will be something more profound.

MyBatis part

5, the difference between the $ and # mybatis of?

Answer: They can come to pass two parameters, but can be # ways sql injection, while $ string splicing is handled, there may be problems sql injection.

Above there is a critical point has not answered it, that is at the pretreatment # {}, the parameters will partially replaced by a placeholder, into a sql statement as follows?:

  1. select * from user where name = ?;

The $ {} is just a simple string concatenation, the dynamic analysis stage direct splicing became final sql statement:

  1. select * from user where name = 'zhouq';

6, $ # with usage scenarios?

The problem I do not understand how to get, then the answer is $ splicing table name used in time, other times when passing parameter values ​​with #.

7, dao interfaces with xml file mybatis inside the sql is how to establish a relationship?

Here, when asked to compare Mongolia circle, and then to answer is: mybatis will first parse the xml files, xml files inside a namespace (namespace), where you can build relationships with dao, then each piece of xml in sql have an id in association with dao interface. . .

The interviewer then said: "If I have two xml files that are related to this dao relationship, that is not a conflict?" And then, I think counsels.

My answer above is too general, there is definitely a problem, I suggest you take a look into the principle mybatis.

mybatis here is gone.

database

Ask is that you usually have to use the database to do more of what is, of course, mysql.

8, mysql locking mechanism?

The interviewer asks is that you understand locking mechanism mysql Mody? I just answer a row lock out. Then the other did not think, you know, the other forgotten.

I suggest you look into that as well as table locks, page locks, and so on.

9, an exclusive lock & shared lock you know?

This place I thought for a moment that usually do not know much. Real-time, the usual small business we basically did not use these systems may be useful to the place, nor to care about it.

Then, the interviewer said the following scenario questions, and then let the solution.

10, the problem scenario: A thread is a process data, such as debit, or update status when other threads it needs to be blocked, such as B, these pieces of data can no longer operate, including query does not work, and the like to give A thread after processing is complete, B can be processed. A is B with the same service code generated non different services. To lock the database to achieve, how to achieve?

I ask this question, the interviewer very patiently explained the scene, and then asked me if I had to think of something? In fact, I wanted to examine the issue of database locks above.

11, mysql index is how to achieve?

The answer is B + tree, then continue to ask the interviewer: "can roughly describe the general structure of the B + tree?." I did not understand how this piece of content, direct recognize counsels.

Cache coherency

This content is written on my project have used the multi-level caching scheme, then this one interviewer asked these questions on the use of the cache might encounter below.

12, caching breakdown, penetration cache, the cache avalanche?

13, how hot data fail to solve?

These two issues, try to understand before too, but not organized into their own things, the interview also say foggy.

14, first delete the cache or to update the database, and why?

Here I am talking about: is to delete the cache, and then update the database , but this is wrong , there is a very big problem.

Think of such a scenario:

If a thread A first delete the cache, and then to update the database, then it deleted the cache has not been updated to the database of the intermediate time, thread B came in and found the cache not, read library, or read at this time or old data, and then update the cache to go. At this point A and only then writing new data to the database.

In this case it gave rise to a typical question is " double the inconsistency ."

Discussions on this issue: "cache update routine" - Chen Hao teacher

kafka

15, kafka architecture, including what roles?

The problem I do not know how to start to answer, he said had a Broker, then the interviewer reminds a bit: "? There is not our usual producer, consumer Yeah what do" Well, I said there are producers, consumers, Yeah, and so on topic.

This process, the interviewer also mentioned that usually when we built it to be configured to write something, etc., as described on the official website to say the line.

There are other such as Partition, consumer groups, there is a major zk up.

It is recommended that you properly put these concepts kafka inside, they belong to, take architecture diagram she painted it. Otherwise really critical time really can not tell, but he mentioned that you and understand. Like this is certainly not interview you said, not the interviewer said.

16, kafka smallest unit of work?

This question was also Mongolia circle, in fact, that when we write the code, use kafka time. We need to use the most basic components, such as producers, consumers, theme, offset and so on.

If you encounter this problem, it is best to ask the interviewer.

17, kafka message duplication consumption? Idempotent how to do?

At first the interviewer said, you know kafka message repetition problem? There are not encountered.

My answer is that there will be a message repeated consumption problem. In the end we did this consumption data processing power, etc. to solve.

Then the interviewer continued only question is: how do idempotent, I say by setting the data version number, as well as a unique index database and so on.

Interviewer: "ok".

This problem, if you tell the interviewer produce a repetitive consumption, such as repeated delivery time, consumption of time due to the offset did not handle so on cause, I think it might be better.

18, kafka ack mechanism? Ack in the cluster is how to achieve?

Here I can only answer on the ack mechanism is valid, but the realization of the principle did not answer up.

Redis

19, which has Redis data structures

The most common use is String, as well as List, Hash, Set, ZSet.

I did not ask other content.

But like Redis Why so fast this problem, I think you should go to understand, other small partners often encountered. That is multiplexed What the hell is?

Source

20, where the interviewer asks you usually have not read some of the source code? The framework is also OK? JDK is required.

Then I said looked HashMap source, then barabara said a general of Kazakhstan put, get the process, its structure is what it looks like.

This process also asked about how to determine whether two objects are equal? Namely == and equals knowledge points.

Other no longer continue to ask. Here the entire electrical surface process is completed, he said 10 working days to reply will give me the interview situation. The whole process lasted about 40 minutes look.

I know, cool.

To sum up

Although the above modules sequentially changed, but the problems inside each chunk are in accordance with the order, are substantially wider scope to ask.

Like database locks, the thread pool, cache problem these contents are almost always in the form of the kind of chain gun, until you touch the bottom .

Through this interview, I experienced the gap. However, the more direction.

Warn us some things:

  • Usually accumulate output: or teach others is the best way to learn, look no practice, a few days to forget.

  • After the first deep wide: in-depth study, and not just remain at the level of use of the API, a piece of in-depth understanding of the system, go and get the other.

  • Build on our knowledge: the contents of their own learning form blog or at any maps worth mentioning, remember these fragmented content, organized into their own knowledge.

  • Do not have luck: Do not bare surface, or if they have a sort of multi-look, more than ready to prepare. Maker of the interview will dig the deepest part of you, not to think back only some of the interview questions is ok, the problem is back endless. Cramming basically pass the test. If you are on the go in the back of the questions, then you are powerful, admire.

  • Once in a while I went to the interview: Do not learn from me, to be a company more than three years, did not go out half-way through the surface, out of things to know, what is the need to add.

Some possible answers to these questions are not too full, you need to do it.

I hope this article help you, even if only one point, is worth it. If there are some points you do not understand, when you are going to add.

Do not wait too long in their comfort zone, or get out. Out to mix, sooner or later have to repay!

 

Wonderful review:

Relationship in Java hashCode () and equals (): The point of the interview

Connected to the container [Docker series -7]

Now the technology wave, we in the end what to do?

 

highly recommended:

"Java technology geek" knowledge planet Limited Time Offer join now only  50  yuan, only before 1000, Jibukeshi or never. As early as possible action!

https://t.zsxq.com/J6Em2nU

 

Introducing:

Java technology geeks public number, is founded by a group of people who love Java technology development, focused on sharing of original, high-quality Java articles. If you feel that our article is not bad, please help appreciated, watching, forwarding support, encourage us to share a better article.

 

Guess you like

Origin www.cnblogs.com/justdojava/p/11098447.html