`
jnullpointer
  • 浏览: 15552 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论
文章列表
这是一篇分布式可扩展架构设计的基础文章,看了以后觉得很受用,分享给各位看一下。附件是原文,原文链接:http://aosabook.org/en/distsys.html Open source software has become a fundamental building block for some of the biggest websites. And as those websites have grown, best practices and guiding principles around their architectures have emerged. This c ...
之前看过hongjiang对ReferenceQueue的分析http://hongjiang.info/java-referencequeue/,很赞的分析水准。仔细看完后,总是感觉有几个点还不是非常透彻,现在揣测着补充一下。 一.Reference类的pending成员     pending是由jvm来赋值的,当Reference内部的referent对象的可达状态改变时,jvm会将Reference对象放入pending链表。 实现的逻辑在referenceProcessor.cpp的enqueue_discovered_reflist方法 void ReferenceProcess ...
Selector的wakeup的分析可以看http://www.iteye.com/topic/1113639 很久之前看过这篇文章,最近重新看,又有新的理解了。 selectNow的选择过程是非阻塞的,select(timeout)和select()的选择过程是阻塞的。 sun.nio.ch.PollSelectorImpl类中 protected int doSelect(long timeout) throws IOException { if (channelArray == null) throw new ClosedSe ...
这两天重新看了一下java.nio.channels.spi.AbstractInterruptibleChannel的代码,感觉又有一些收获,记录一下。AbstractInterruptibleChannel实现了InterruptibleChannel接口。InterruptibleChannel接口的描述非常重要,直接影响AbstractInterruptibleChannel的行为: A channel that implements this interface is asynchronously closeable: If a thread is blocked in an I/ ...
一.获取Unsafe,通用的办法利用反射机制 Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); unsafeField.setAccessible(true); Unsafe unsafe = (Unsafe) unsafeField.get(null); 二.Unsafe自己对调用者的检查 public static Unsafe getUnsafe() { Class cc = sun.reflect.Reflection.ge ...
Netty是个值得花时间学习的框架,即使一个不起眼的程序,都有值得深入学习的地方。比如:io.netty.util.internal.PlatformDependent类中,对异常的处理就非常巧妙。 经常会碰到这种情况,实现一个接口,接口签名是没有申明异常的。但在实现中却需要捕获异常。比如:guava包中的通用接口 public interface Supplier<T> { /** * Retrieves an instance of the appropriate type. * The returned object ...
1.代码中的'<<'写法 private long ix(int i) { return address + (i << 0); } 这个就等价下面这种写法,但为什么用(i << 0) private long ix(int i) { return address + i; } 我琢磨了很久,以为有什么特殊的考虑因素,后来看了其他openJDK6以后的代码才恍然大悟。DirectByteBuffer类是由Direct-X-Buffer.java作为模板生成的。生成的像 ...
private Node enq(final Node node) { for (;;) { Node t = tail; if (t == null) { // Must initialize if (compareAndSetHead(new Node())) tail = head; } else { node.prev = t; //如果设置t ...
Global site tag (gtag.js) - Google Analytics