File tree Expand file tree Collapse file tree 6 files changed +54
-17
lines changed
src/main/java/com/algorithm/study/demo Expand file tree Collapse file tree 6 files changed +54
-17
lines changed Original file line number Diff line number Diff line change 1- ![ enter image description here] ( https://drscdn.500px.org/photo/286065929/q=80_m=2000/v2?user_id=20361103&webp=true&sig=5246d3ececc0976199a64920c236729da09957c8ad23afa513084c27681961e4 )
2-
31| 🍏 | 🍎 | 🍐 | 🍈 | 🥑 | 🥔| 🍠 | 🥝 | 🍱 | 🥞 |🌽| 🥦
42| :--------: | :---------: | :---------: | :---------: | :---------: | :---------:| :---------: | :-------: | :-------:| :------:| :------:| :--------: |
53| [ JAVA基础] ( #JAVA基础 ) | [ JVM知识] ( #JVM知识 ) |[ 开源框架知识] ( #开源框架知识 ) | [ 操作系统知识] ( #操作系统 ) |[ 多线程与并发] ( #多线程与并发 ) |[ TCP与HTTP] ( #TCP与HTTP ) | [ 架构设计与分布式] ( #架构设计与分布式 ) |[ 数据结构与算法] ( #数据结构与算法 ) |[ 数据库] ( #数据库知识 ) | [ 消息队列] ( #消息队列 ) |[ 缓存] ( #缓存 ) | [ 搜索] ( #搜索 )
64### 求职、技术交流微信群
75<img src =" https://github.com/randian666/algorithm-study/blob/master/image/871550714055_.pic_hd.jpg " width =" 250 " height =" 280 " />
6+ ### Java并发编程实战
7+ <img src =" https://github.com/randian666/algorithm-study/blob/master/image/WechatIMG105.jpeg " />
88
99### JAVA基础
1010 - [ String,Stringbuffer,StringBuilder的区] ( http://www.cnblogs.com/su-feng/p/6659064.html ) 。
Original file line number Diff line number Diff line change 2020 <artifactId >cglib</artifactId >
2121 <version >2.2.2</version >
2222 </dependency >
23+ <!-- https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper -->
24+ <dependency >
25+ <groupId >org.apache.zookeeper</groupId >
26+ <artifactId >zookeeper</artifactId >
27+ <version >3.4.6</version >
28+ </dependency >
2329 </dependencies >
2430 <build >
2531 <plugins >
Original file line number Diff line number Diff line change 1+ package com .algorithm .study .demo ;
2+
3+ /**
4+ * @Author: liuxun
5+ * @CreateDate: 2019/2/23 下午3:20
6+ * @Version: 1.0
7+ */
8+ public abstract class AbstractLoadBalance {
9+ public String select (String name ){
10+ String newName ="hello " +name ;
11+ doSelect (newName );
12+ return newName ;
13+ }
14+ protected abstract String doSelect (String name );
15+ }
Original file line number Diff line number Diff line change 1111 */
1212public class MainTest {
1313 public static void main (String [] args ) {
14- Object counter = new Object ();
15- ReferenceQueue refQueue = new ReferenceQueue <>();
16- PhantomReference <Object > p = new PhantomReference <>(counter , refQueue );
17- counter = null ;
18- System .gc ();
19- try {
20- // Remove 是一个阻塞方法,可以指定 timeout,或者选择一直阻塞
21- Reference <Object > ref = refQueue .remove (1000L );
22- if (ref != null ) {
23- System .out .println ("counter gc" );
24- }
25- } catch (InterruptedException e ) {
26- // Handle it
27- }
28-
14+ // Object counter = new Object();
15+ // ReferenceQueue refQueue = new ReferenceQueue<>();
16+ // PhantomReference<Object> p = new PhantomReference<>(counter, refQueue);
17+ // counter = null;
18+ // System.gc();
19+ // try {
20+ // // Remove 是一个阻塞方法,可以指定 timeout,或者选择一直阻塞
21+ // Reference<Object> ref = refQueue.remove(1000L);
22+ // if (ref != null) {
23+ // System.out.println("counter gc");
24+ // }
25+ // } catch (InterruptedException e) {
26+ // // Handle it
27+ // }
28+ AbstractLoadBalance randomLoadBalance =new RandomLoadBalance ();
29+ String name =randomLoadBalance .select ("liuxun" );
30+ System .out .println (name );
2931 }
3032}
Original file line number Diff line number Diff line change 1+ package com .algorithm .study .demo ;
2+
3+ /**
4+ * @Author: liuxun
5+ * @CreateDate: 2019/2/23 下午3:21
6+ * @Version: 1.0
7+ */
8+ public class RandomLoadBalance extends AbstractLoadBalance {
9+ @ Override
10+ protected String doSelect (String name ) {
11+ System .out .println ("doSelect run name is " + name );
12+ return name ;
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments