Summarization - Backup Consolidation - knowledge problem comb

One .javase

1.jdk1.8 new features

  • Faster search - red-black tree
  • Conduct parametric less code - Lambda
  • Powerful Stream API - Stream
  • Suitable for parallel - Parallel
  • To maximize the reduction of null pointer exception - Optional

2.JVM principle structure, GC working machine system Detailed

JVM includes four parts

1. The execution engine class loader 2. 3. 4. The native method interface memory area

JVM garbage detection, recovery algorithm:

1. Mark - Clear (Mark-sweep) 2 Copy (Copying) 3 tag - finishing (Mark-Compact) 4 generational collection algorithm.

3, Map or storage principle of HashMap

A: + HashMap is an array of a structure composed of chain, with particular reference to: the realization of the principle HashMap

4, which method Java Object class have?

  • protected Object clone () Creates and returns a copy of this object.
  • boolean equals (Object obj) indicating whether some other object with this object is "equal."
  • protected void finalize () when the garbage collector to identify additional references to the object does not exist, this method is called by the garbage collector objects.
  • Class <?> GetClass () Returns the runtime class of this Object.
  • int hashCode () Returns the hash code value for this object.
  • void notify () wake up a single thread waiting on this object's monitor.
  • void notifyAll () wakes up all threads waiting on this object's monitor.
  • String toString () Returns a string representation of the object.
  • void wait () call this object before in other threads notify () method or the notifyAll () method causes the current thread to wait.
  • void wait (long timeout) calls this object before in other threads notify () method or the notifyAll () method, or a specified amount of time, leading to the current thread to wait.
  • void wait (long timeout, int nanos) calls this object in the other thread notify () method or the notifyAll () method, or some other thread interrupts the current thread, or more than one of the actual amount of time before, leading to the current thread to wait.

5, Thread class in what ways, and how many ways to achieve thread synchronization

Thread class common method

String getName () Returns the name of this thread.
void setName (String name) change the name of this thread equal to the argument name.
int getPriority () returns the priority of the thread.
void setPriority (int newPriority) to change the thread priority.
boolean isDaemon () Tests if this thread is a daemon thread.
void setDaemon (boolean on) Marks this thread is a daemon thread or a user thread.
SLEEP void static (Long of millis)
void interrupt () Interrupts this thread.
static void yield () to pause the currently executing thread object, and perform other threads.
void join () Waits for this thread.
RUN void ()
void Start ()

Object class method inherited from the  

void notify()

void wait()

Synchronously:

1. synchronization method

2. The sync block

3. Use the special field variables (volatile) implement thread synchronization

4. reentrant locks for thread synchronization

5. Thread Synchronization implemented using local variables

6, distributed, clustered environment, how to refresh the cache, and how to keep pace?

A, how to refresh the cache?

1, regularly updated

2, take the initiative to refresh the cover, each frame has its own cache refresh mechanism, or the cache invalidation mechanism, Redis and Ehcache Take, for example, they have built-in mechanisms expired, when another initiative to refresh the cover, just to obtain the corresponding the key data can be covered

B, how to keep the cache synchronized? This redis has built-in cluster synchronization mechanism, namely replication, specific reference: Based Redis distributed cache, Ehcache also distributed cache synchronization configuration, you only need to configure different server addresses, reference: Ehcache distributed cache synchronization

7. Please write a simple singleton

 

public class Singleton {
  private Singleton(){

  }
  private static class SingletonHolder{
    private final static Singleton instance=new Singleton();
  }
  public static Singleton getInstance(){
    return SingletonHolder.instance;
  }
}

8. The four property transactions is

Atomicity (Atomicity): A transaction is a complete operation. Each transaction step operation is indivisible (atoms); or perform or not perform
consistency (Consistency): When the transaction is completed, the data must be in a consistent state
isolation (Isolation): data of all concurrent modifications transactions are isolated from each other, indicating that the transaction must be independent, it should not in any way affect or depend on other matters
permanent (Durability): after the transaction is complete, modify its database is permanently kept, the transaction log can be maintained Affairs permanent

9. Distributed Transaction Solutions

First, the two-phase commit (2PC / 3PC)
Second, transactions compensation (TCC)
Third, local message table (asynchronous ensure)
four, MQ transactional messaging
five, Sagas transaction model

 

Two, sql

1.Mysql index What types?

From the perspective of a data structure

Mysql present, there are several index types: FULLTEXT, HASH, BTREE, RTREE

Logically

Common Index: only speed up queries
unique index: speed up queries + column value unique (there may be null)
primary key index: speed up queries + column value uniquely (not have null) + table only a
composite index: multi-column value composed of an index, designed for a combination of search, its efficiency is more than the combined index
full-text indexing: the content of the text word segmentation, search

2. Existing student a table structure (student-id, class-id, name), please write the statistics the number of students per class sql statement


SELECT class name, COUNT (Student ID) number
FROM LEFT JOIN table class student class table ON table. = Number of classes the student table. Class
GROUP BY class name

3. What are lock database, database deadlock causes and how to avoid

I. transaction between the resource access order alternating
two. Concurrent modification of the same record
three Index improper full table scan
four large range block and wait for another transaction

4.Mybatis when the entity attribute is inconsistent with the database fields will be a problem, such as database fields or entity attributes than the opposite situation?  

A: The original ecological and does not complain, but when more than physical property database field this property does not work, physical properties than the database field, the database fields are not mapped. However, with some auxiliary frame, is inserted into the entity attribute read than being given entity attribute database fields.


5, when data table A, B do combination index field, use A alone or B alone it will effect the index? (Using a query like how the index effect)


Answer: Look A, B make combinations of two when the index field, who is in front of, behind who, if the first A, then A alone will effect the index, B alone is not used, and vice versa. Similarly, the use of fuzzy query like, if you just use the preceding%, then there is the effect of the index, if the numbers match the double%, then the effect is no index

6, a sql execution time is too long, how do you optimize, from what?

1, to see whether involving multiple sql tables with table or sub-queries, and if so, to see whether it can conduct business split, redundant or related field combined into a temporary table (optimize business and algorithms)
2, involving the list of query, can be sub-table query, the results after single-table queries field integration
3. If the above two can not operate, have to query the list, consider the query conditions corresponding indexed. Speed up queries
4, the history table separation (such as transaction flow table) for a large number of tables
5, separated from the main database, separate read and write, read and write to reduce the pressure against the same table at the same time, as the master-slave synchronization, mysql has built the binlog achieve master-slave synchronization
6, explain sql statement analysis, view the execution plan, analysis of the index is to spend, and so on analysis of scan lines
7, see mysql execution logs to see if there are other aspects of
personal understanding: from the root up that is slow query mysql take up more memory, then you can consider this aspect to the discretion of hand

7, when a database to store the date format, time zone conversion problem of how to consider?

Use TimeStamp, referring to the reasons: Java programming time zone conversion problems encountered

 

8, boolean type, amount of class type, time, type of entity attribute for the data type database fields are?

Boolean ,tinyint(1);

BigDecimal,decimal(17,6) ;

Date, dateTime / need to use the timestamp of when the country;

The principle of entity attributes are used packaging

9. What are optimistic and pessimistic locking of the database is?

Concurrency Control task database management system (DBMS) is isolated and ensuring uniformity and unity without destroying the transaction database when multiple transactions simultaneously access the same data in the database.
Optimistic concurrency control (optimistic locking) and pessimistic concurrency control (pessimistic locking) concurrency control techniques are mainly used.
Pessimistic locking: assume concurrency violation occurs, the shield may violate data integrity of all operating
optimistic lock: Suppose concurrency conflicts will not occur, if only to check data integrity violation when a commit operation.

Guess you like

Origin www.cnblogs.com/liboware/p/11964416.html