辣椒の酱

尚未执佩剑,转眼即江湖


  • Home

  • Tags

  • Categories

  • Archives

  • message

  • master

Java设计模式之观察者模式

Posted on 2018-11-15 | In java , 设计模式

定义

在阎宏博士的《JAVA与模式》一书中开头是这样描述观察者(Observer)模式的:
观察者模式是对象的行为模式,又叫发布-订阅(Publish/Subscribe)模式、模型-视图(Model/View)模式、源-监听器(Source/Listener)模式或从属者(Dependents)模式。
观察者模式定义了一种一对多的依赖关系,让多个观察者对象同时监听某一个主题对象。这个主题对象在状态上发生变化时,会通知所有观察者对象,使它们能够自动更新自己。

Read more »

Immutable Object(不可变对象)模式

Posted on 2018-11-13 | In java , java基础

多线程下,一个对象会被多个线程共享,存在多线程并发地修改对象的属性,需要做些同步访问控制,
如显示锁,CAS操作,会带来额外的开销和问题,如上下文切换、等待时间、ABA问题。Immutable Object
模式意图通过使用对外可见的状态不可变的对象,使得天生具有线程安全性。

Read more »

elasticsearch6 query 全文查询与词项查询

Posted on 2018-11-13 | In java , elasticsearch6

query

全文查询

  1. QueryBuilders.matchQuery(“filed”,”value”).operator(Operator.AND); // 对查询的语句进行分词,分词后的词任意一个匹配doc都能查出来 term query 查询的是词项<分词后的> (eg:Java编程思想) Java编程 term query 不能查到 分词后变成(Java 编程 思想) matchQuery能查到
  2. QueryBuilders.matchPhraseQuery(“field”,”value”);
    对value进行分词,可以自定义分词器,满足两个条件才能被搜到:
    • 分词后的所有词项都要匹配原字段
    • 顺序还需要一致
      Read more »

leetcode-1-Two Sum

Posted on 2018-11-11 | In algorithm

description

Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].

Read more »

Hello World

Posted on 2018-11-11 | In think

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Read more »

Hello blog

Posted on 2018-11-11 | In think

this is a first blog.

It's a very exciting time

  • make a plan
  • execute
  • have a harvest
  • come on
1
2
3
4
5
public void start(){
while(true){
System.out.println("struggle!");
}
}

2019成长记01

Posted on 2019-10-30 | In private
咦,这是一篇加密文章,好像需要输入密码才能查看呢!
Read more »
1…1112
辣椒の酱

辣椒の酱

117 posts
42 categories
84 tags
RSS
© 2020 辣椒の酱
Powered by Hexo
|
Theme — NexT.Pisces v5.1.4