Chen Jian's Java Blog 

Tips for traversing a tree with stacks

by Chen Jian


Posted on 2016-07-23 12:00 in Computer Theory


  Here are the tips of my solution: You always push the root to the stack first The most difficult part is: when you see a node on the top of element, should you go on to push its children, or pop it to print it? ...


各种存储的latency

by Chen Jian


Posted on 2014-06-21 12:00 in Computer Theory


1. Cache - 几个ns 2. Main Memory  - 10-100 ns 3. Secondary Storage(一般是磁盘) - HDD 3-10ms, SSD 0.1ms 4. Tertiary Storage(磁带,DVD) - 秒级或分钟级


二叉查找树与平衡二叉树

by Chen Jian


Posted on 2014-03-13 12:00 in Computer Theory


内容编译自网络 Binary Search Tree 什么情况下会出现O(n) ? 如果树的根结点没选好,一棵树变成一个列表: 平衡二叉查找树 -  可以自动旋转 参考: http://en.wikipedia.org/wiki/Binary_search_tree http://www.cnblogs.com/huangxincheng/archive/2012/07/21/2602375.html ...


三种i/o模式:异步模式与阻塞模式的组合

by Chen Jian


Posted on 2013-12-06 12:00 in Computer Theory


阻塞且同步 : read()方法要等到读到数据了才返回,如果没数据就会一直等 非阻塞且同步 : read()方法如果发现当前没数据,就会返回; 调用者可以去做别的事情。然后过段时间再读(轮询) 非阻塞且异步 :read()方法如果发现当前没数据,会返回; 调用者可以去做别的事情,也不用再轮询,等操作系统把数据读好了,会通过回调方式把数据交给调用者。 阻塞并异步 : 没有这样的组合,这种组合也没有意义 归纳一下:   阻塞/非阻塞:读不到数据方法就不退出,就是阻塞 ...


收藏:特殊IP地址段

by Chen Jian


Posted on 2013-10-24 12:00 in Computer Theory


一个结点要向注册中心告知自己的IP,应该用本机多个IP中的哪个? 看这里 http://en.wikipedia.org/wiki/Reserved_IP_addresses ,避免使用虚拟IP、多播IP和回环IP.


CONNECTION_TIMEOUT和SO_TIMEOUT的区别

by Chen Jian


Posted on 2013-09-28 12:00 in Computer Theory


CONNECTION_TIMEOUT:建立连接超时 SO_TIMEOUT: 读数据超时,如: 引用 SO_TIMEOUT is the timeout that a read() call will block. If the timeout is reached, a java.net.SocketTimeoutException will be thrown


Http Chunked transfer encoding的作用

by Chen Jian


Posted on 2013-08-21 12:00 in Computer Theory


有利于 长连接下的流式转输 摘自 http://en.wikipedia.org/wiki/Chunked_transfer_encoding 引用 Chunked encoding has the benefit that it is not necessary to generate the full content before writing the header, as it allows streaming of content as chunks...


JSR 356: Java Websocket规范

by Chen Jian


Posted on 2013-08-19 12:00 in Computer Theory


http://www.jcp.org/en/jsr/detail?id=356 Final Release: http://jcp.org/aboutJava/communityprocess/final/jsr356/index.html , 批准于22 May, 2013 并且它是JEE 7规范的一部分


有个网站提供了全套的websocket测试用例

by Chen Jian


Posted on 2013-08-19 12:00 in Computer Theory


http://autobahn.ws/testsuite


收藏一个东西:基于websocket的RPC和pub/sub协议

by Chen Jian


Posted on 2013-08-18 12:00 in Computer Theory


[url]http://wamp.ws/ [/url] 构建在websocket之上的RPC协议和pub/sub协议


对服务端推送(Server Push)比较好的解释

by Chen Jian


Posted on 2013-08-13 12:00 in Computer Theory


摘自: http://www.javaworld.com/javaworld/jw-02-2009/jw-02-servlet3.html?page=2 Service streaming (streaming) allows a server to send a message to a client when an event occurs, without an explicit request from the client. In real-world...


websocket的ping和pong

by Chen Jian


Posted on 2013-06-24 12:00 in Computer Theory


作用:A Ping frame may serve either as a keepalive or as a means to  verify that the remote endpoint is still responsive. Ping和Pong的关系:   1. Upon receipt of a Ping frame, an endpoint MUST send a Pong frame in response...   2. A Pong frame...


websocket的握手与数据传输

by Chen Jian


Posted on 2013-06-19 12:00 in Computer Theory


关于握手 ,转一张 图 : 连接建立后,客户端和服务端就可以 全双工 地通迅。 数据传输以"message"为单位. 一个message由一个或多个frame组成,每个frame等于一个 header + payload.


关于comet、websocket的比较

by Chen Jian


Posted on 2013-06-18 12:00 in Computer Theory


首先要明白websocket不是http协议,只不过有些相似的地方: 报文格式相似(但不相同),都被浏览器支持,服务商品都是80等。 而comet是基于http协议的. 再推荐一篇文章,里面总结了websocket相比于comet在性能方面的优点: Ajax、Comet、HTML 5 Web Sockets技术比较分析


Stream-based Transport

by Chen Jian


Posted on 2013-06-18 12:00 in Computer Theory


普通的传输是指发送方会在发完一条逻辑消息后,显式地发一个end of stream标识,在接收方眼里,一条消息就是一个packet. 而在Stream-based Transport中,发送方不发送end of stream标识,而只是不停地发字节,接收方需要按照预定义的报文协议自己组合byte,解析出逻辑消息。