Chinaunix首页 | 论坛 | 博客
  • 博客访问: 57906
  • 博文数量: 9
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 145
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-14 22:57
个人简介

沧海之一粟

文章分类

全部博文(9)

文章存档

2015年(2)

2014年(7)

我的朋友

分类: Java

2014-11-25 10:53:26

You can think about multithread(原文是it,我把它替换为multithread) in "pizza terms". You went to pizza cafe, and couple of other guys entered with you as well. Each one placed his order and then sat to his own table. Pizza boxes to be arrived then and each of you start eating his own meal.

Here, the cafe is a singleton, pizza boys are CPU cores, you and other customers are threads, orders and pizza are input and output data respectively, table is a piece of memory.

As you can see, each thread is served with his own piece of memory so CPU can distinguish your data and don't mix up. As you asked about stack, it's not a significant player here because each thread has it's own stack (as a part of your memory chunk).


原文标题是:how multiple threads invoke singleton object's method and work on them?
原文出自stackoverflow,地址我就不加了。因为我怕这篇文章审核不通过!
作为一个人类,我们经常受到这种审核的约束!

阅读(1189) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~