- 浏览: 748304 次
- 性别:
- 来自: 上海
-
文章分类
- 全部博客 (419)
- 杂软粉墨 (2)
- 创意灵感 (3)
- 经验记录 (137)
- 开源轨迹 (2)
- sip-communicator (2)
- 闲侃杂谈 (8)
- 问题交流 (24)
- 概念模式 (32)
- 难点备案 (5)
- JwChat (1)
- 中国象棋 (1)
- 教育探索 (6)
- 英语研究 (58)
- 星际争霸 (1)
- 电信知识 (1)
- 软件架构 (3)
- 哲学探索 (26)
- 算法灵魂 (8)
- 近视探索 (6)
- 数学数学 (3)
- 牛角钻尖 (23)
- 至强文言 (3)
- 数据结构 (1)
- 宇宙物理 (2)
- 网络架构 (3)
- 游戏领域 (4)
- 图形处理 (2)
- 修炼之路 (8)
- 读书天地 (20)
- 编解乱码 (2)
- 概念探索 (8)
- 格物致知 (1)
- 其它语言 (1)
- 测试领域 (3)
- 文化风流 (1)
- JQuery (1)
- 網頁領域 (1)
- Unix/Linux (1)
- Inside JVM (1)
- 异常分析 (1)
最新评论
-
suyujie:
引用
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
iamzhoug37:
您能说一下"局部变量不受文本顺序限制" 是 ...
声明前为什么能赋值却不能输出,都是使用
public class DataRace { static int a = 0; public static void main() { new MyThread().start(); a = 1; } public static class MyThread extends Thread { public void run() { System.out.println(a); } } }
以上两个线程间就存在简单数据竞争
The second thread could be scheduled immediately, printing the initial
value of 0 for a
. Alternately, the second thread might
not
run immediately, resulting in the value 1 being printed
instead. The output of this program may depend on the JDK you are
using, the scheduler of the underlying operating system, or random
timing artifacts. Running it multiple times could produce different
results.
There is actually another data race in Listing 1, besides the obvious
race of whether the second thread starts executing
before or after the first thread sets a
to
1. The second race is a visibility race: the two threads are not using
synchronization, which would ensure visibility of data changes across
threads. Because there's no synchronization, if the second thread runs
after the assignment to a
is completed by
the first thread, changes made by the first thread may or may
not
be immediately visible to the second thread. It is possible
that the second thread might still see a
as
having a value of 0 even though the first thread already assigned it a
value of 1. This second class of data race, where two threads are
accessing the same variable in the absence of proper synchronization,
is a complicated subject, but fortunately you can avoid this class of
data race by using synchronization whenever you are reading a variable
that might have been last written by another thread, or writing a
variable that might next be read by another thread. We won't be
exploring this type of data race further here, but see the "Synching
up with the Java Memory Model"
sidebar
and the Resources
section for more
information on this complicated issue.
Synching up with the Java Memory Model
发表评论
-
关于方法访问控制符protected
2012-11-29 10:38 1268http://bbs.csdn.net/topics/3902 ... -
一个基本问题关于引用的
2012-05-15 10:20 1130问: int a = 1; Integer b = new ... -
我對面向對象和過程的理解。
2012-05-02 08:30 1068我的一些理解。 面向过程,是对客观现象的描述,感觉是有一个上 ... -
stack and heap
2012-01-13 23:17 1054我觉得是根据应用方式 和本身特性 才将内存分区的,目的是提 ... -
program experience conclusion
2011-07-11 15:35 10681. check parameters for validit ... -
PreparedStatement's possible designated parameter
2011-04-29 13:45 991though it's nearly impossible t ... -
clean Log4j
2011-04-12 11:19 1069import org.apache.log4j.BasicCo ... -
about abstract class
2011-04-02 10:34 871yes, we do know abstract class ... -
cvs operations on linux
2011-03-25 09:40 1016http://www.linuxhowtos.org/Syst ... -
regex to exchange two parts
2011-03-24 17:09 1096public class Test { public ... -
About the database locking
2011-03-09 11:02 967http://en.wikipedia.org/wiki/Lo ... -
how to send soap message in java
2011-03-08 10:29 1898import java.io.BufferedReader; ... -
About ShutDownDemo
2011-03-07 15:02 985public class ShutdownDemo { p ... -
How do you know if an explicit object casting is needed
2011-02-24 16:33 1192通俗来讲,不可能将一只是猫的动物强转为狗 再说Graphic ... -
有关MimeUtility
2011-02-24 13:11 3368import java.io.UnsupportedEncod ... -
C#连接sql server 2008的一件2事
2011-02-24 09:01 2157once upon a time, i came upon o ... -
Shadowing, Overriding, Hiding and Obscuring
2011-02-22 15:15 1168当子类属性与父类属性重叠时 这种叫法上是shadowi ... -
JAXP usage
2011-02-16 16:07 1104import java.io.ByteArrayInputSt ... -
运行一个类,如果classpath中路径带空格就加双引号
2011-02-11 11:25 2810注意是这样加: java -cp .;"d:\my ... -
关于ClassPath中的current directory
2011-01-28 16:40 1156Given: 1. package com.company. ...
相关推荐
By 2020, we (as the human race) are expected to produce ten times that. With data getting larger literally by the second, and given the growing appetite for making sense out of it, in 2004 Google ...
Ensuring that this code will run without unforeseen race conditions is an the order of magnitude harder. RxJava is the tool that can help write code for such tasks. In this book a novice developer ...
Does the thought of building your very own iPhone app make your heart race and your pulse quicken? If so, Beginning iPhone 3 Development: Exploring the iPhone SDK is just the book for you. Updated ...
Simple logging configuring for development 275 Deciding what to log 277 Decorators to log function entry and exit 277 Applying the decorators to the Survey code 280 Logging in the debug toolbar ...
Ensuring that this code will run without unforeseen race conditions is on the order of magnitude harder. RxJava is the tool that can help write code for such tasks. In this book a novice developer ...
building your very own iPhone app make your heart race and your pulse quicken? If so, Beginning iPhone 3 Development: Exploring the iPhone SDK is just the book for you. Updated and revised for ...
building your very own iPhone app make your heart race and your pulse quicken? If so, Beginning iPhone 3 Development: Exploring the iPhone SDK is just the book for you. Updated and revised for ...
race_simple:简化的演员种族——要么White或POC(有色人种) words: 说的字数 sentences:说出的句子数(未在已发表的文章中使用,但提供参考和上下文) data/character-word-counts-csvcharacter + word为我们分析...
Data Format Section 5.19. Summary Exercises Chapter 6. I/O Multiplexing: The select and poll Functions Section 6.1. Introduction Section 6.2. I/O Models Section 6.3. select Function ...
Guidelines for Avoiding Race Conditions . . . . . . . . . . 183 Semaphores . . . . . . . 184 Portability Issues 186 Events from Overwritten Scheduled Values . . . . . . . . 186 Disabled Scheduled ...
3.7 Learn to Inspect Data: Variables and Expressions . . . . 29 3.8 A Debug Session on a Simple Example . . . . . . 30 4 Fixing Memory Problems . . . . . . . . . . . . 33 4.1 Memory Management in C/...
3.4 User Data Manager (Dealing with Player Stats Such as Health, Lives, etc.)....37 3.4.1 Script Breakdown..........................................39 4. Recipes: Common Components 41 4.1 Introduction...
param_object:一个simple JavaScript object,所有的name/value都必须是字符串,例如(this.setPostParams({ "Mari": name });)。 - 返回 void [编辑本段]SWFUpload中的事件 SWFUpload在运行过程中提供了...
EurekaLog 7.5 (18-August-2016) 1)..Important: Installation layout was changed. All packages now have version suffix (e.g. EurekaLogCore240.bpl). No files are copied to \bin folder of IDE....