Computer Theory

Condition variable related code is hard to understand. So let me explain

There are a few strange things about Condition related code in Java concurrency. I’ll use the following code to show you. The code is about one cup and two threads. One thread is trying to fill it, the other to drink from it. The code uses explicit Lock + Condition API. But what I’m going …

Condition variable related code is hard to understand. So let me explain Read More »

Test-and-set Primitive

First of all, it’s not the same as “compare-and-swap”. Sounds similar, but different. What it does is, Set a variable to a new value Return the old value of the variable It’s a hardware primitive, i.e. atomic. On x86 the instruction is `xchg` (There is actually no “test” , is there? ) What can it …

Test-and-set Primitive Read More »

各种存储的latency

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

二叉查找树与平衡二叉树

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

收藏:特殊IP地址段

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

Http Chunked transfer encoding的作用

有利于 长连接下的流式转输 摘自 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 and explicitly signaling the end of the content