As a result of the recent preparation for the interview, dilute scattered some of the common Java problems, the answer to the question is found on the Web site, there is nothing wrong place also ask you to point out the great God. Because it is used to learn, so if a friend found their original do not want this public please m me, I will quickly delete.
What is multi-threaded synchronization in 1.Java?
Under multi-threaded routines, synchronization can control access to shared resources. If there is no synchronization, when a Java thread modifies a shared variable, another thread is using or updating the same variable, which can lead to incorrect results for the program.
2.What is the difference betweenSleep (), suspend (), and Wait () ?
Thread.Sleep () causes the current thread to be in a non-running (not Runnable) state at the specified time. The thread has been holding the object's monitor. For example, a thread is currently in a synchronous block or synchronous method, and other threads cannot enter the block or method. If another thread calls the interrupt () method, it wakes up the "sleeping" thread.
Note: Sleep () is a static method. This means that only the current thread is valid, and a common mistake is to call T.sleep (), where T is a different thread than the current thread. Even if T.sleep () is executed, the current thread goes to sleep, not the t thread. T.suspend () is an obsolete method that uses suspend () to cause a thread to go into a stagnant state, which will hold the object's monitor all the time, and suspend () can cause a deadlock problem.
Object.wait () makes the current thread out of a "non-operational" state, unlike sleep () where wait is the method of object instead of thread.
When Sleep () s calls Object.wait (), the thread first acquires an object lock on the object, the current thread must remain in sync on the lock object, add the current thread to the wait queue, and then the other threads can synchronize the same object lock to invoke Object.notify (), This will wake up the thread in the original wait and then release the lock. Basically wait ()/notify () is similar to sleep ()/interrupt (), except that the former needs to acquire an object lock.
3. Java three major features: polymorphism , inheritance, and encapsulation
What is the difference between 4.equals and = =?
Next, we will continue to tidy up ...
Some common problems with Java interviewing