• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

littlesuccess

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

随笔分类 -  并发编程

Java并发编程实践-16章-Java内存模型
摘要:Program order rule. Each action in a thread happens-before every action in that thread that comes later in the program order.Monitor lock rule. An unlock on a monitor lock happens-before every subsequent lock on that same monitor lock.Volatile variable rule. A write to a volatile field happens-befor 阅读全文

posted @ 2011-11-28 17:25 littlesuccess 阅读(220) 评论(0) 推荐(0)

Java并发编程实践-第二章-线程安全
摘要:Perhaps surprisingly, concurrent programming isn’t so much about threads or locks, any more than civil engineering is about rivets and I-beams. Of course,building bridges that don’t fall down requires the correct use of a lot of rivets and I-beams, just as building concurrent programs require the co 阅读全文

posted @ 2011-11-23 16:01 littlesuccess 阅读(283) 评论(0) 推荐(0)

Java并发编程实践-前言
摘要:Preface前言At this writing, multicore processors are just now becoming inexpensive enough for midrange desktop systems. Not coincidentally, many development teams are noticing more and more threading-related bug reports in their projects. In a recent post on the NetBeans developer site, one of the cor 阅读全文

posted @ 2011-11-21 20:24 littlesuccess 阅读(188) 评论(0) 推荐(0)

Java单例模式Inside Out
摘要:单例模式在Java编程实践中经常用到。单例模式用于保证每个类只有一个实例存在。本文将对Java单利模式进行一个系统深入的介绍。单例模式是为了保证一个类只有一个实例存在。注意,我们所说的每个类只有一个实例存在是相对于一个JVM和一个ClassLoader而言的。由于不同的类装载器装载的类位于不同的命名空间内,所以在同一个JVM还是可以有有不同的类装载器装载的不同的实例。但这些实例是不同的。测试:先建立如下Singleton类:public class Singleton { private static Singleton instance = new Singleton(); ... 阅读全文

posted @ 2011-10-31 16:43 littlesuccess 阅读(319) 评论(0) 推荐(0)

怎样删除一个集合中的对象
摘要:问题:请问下面的那种方法能正确地把字符"B"从集合stringList中删除掉?1 List<String> stringList = new ArrayList<String>();2 stringList.add("A");3 stringList.add("B");4 stringList.add("C");5 stringList.add("B");6 stringList.add("D");7 stringList.add("E&q 阅读全文

posted @ 2011-10-19 18:08 littlesuccess 阅读(581) 评论(0) 推荐(0)

非同步方法能立刻看到同步方法的修改吗?
摘要:问题:有一个类Foo如下:public class Foo{ private int i = 0; public void f(){ System.println("In f() i=" + i); } public synchronized void g(){ //point 1 System.println("In g() i=" + i); i = 1; //point 2 System.println("In g() i=" + i); }}请问如果有两个线程A,B,线程B执行到point 2时,问线程A总会打印出" 阅读全文

posted @ 2011-10-19 11:13 littlesuccess 阅读(150) 评论(0) 推荐(0)

Java并发编程实践-第三章-对象的共享
摘要:3.3.3 ThreadLocal3.3.3 ThreadLocalA more formal means of maintaining thread confinement is ThreadLocal,which allows you to associate a per-thread value with a value-holding object. ThreadLocal provides get and set accessor methods that maintain a separate copy of the value for each thread that use... 阅读全文

posted @ 2011-10-17 15:01 littlesuccess 阅读(252) 评论(0) 推荐(0)

Java并发编程实践-第十三章-Explicit Locks
摘要:Explicit LocksExplicit LockBefore Java 5.0, the only mechanisms for coordinating access to shared data were synchronized and volatile. Java 5.0 adds another option: ReentrantLock.Contrary to what some have written, ReentrantLock is not a replacement for intrinsic locking, but rather an alternative w 阅读全文

posted @ 2011-10-17 14:21 littlesuccess 阅读(226) 评论(0) 推荐(0)

 
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3