|
用户名:keenonjava 笔名:keenonjava 地区: 行业:其他 |
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
Java 6新特性一览 将直接支持JavaScript
- 作者: keenonjava 2005年06月15日, 星期三 14:54 回复(0) | 引用(0) 加入博采
volatile关键字
刚才我讲的太烂了,浪费了大家不少时间,望大家多多包涵!
关于volatile以及cynchronized,还有java的内存模型,下面这篇文章讲的非常清楚,希望对大家有帮助
What does volatile do?
This is probably best explained by comparing the effects that volatile and synchronized have on a method. volatile is a field modifier, while synchronized modifies code blocks and methods. So we can specify three variations of a simple accessor using those two keywords:
int i1; int geti1() {return i1;}
volatile int i2; int geti2() {return i2;}
int i3; synchronized int geti3() {return i3;}
geti1() accesses the value currently stored in i1 in the current thread. Threads can have local copies of variables, and the data does not have to be the same as the data held in other threads. In particular, another thread may have updated i1 in it's thread, but the value in the current thread could be different from that updated value. In fact Java has the idea of a "main" memory, and this is the memory that holds the current "correct" value for variables. Threads can have their own copy of data for variables, and the thread copy can be different from the "main" memory. So in fact, it is possible for the "main" memory to have a value of 1 for i1, for thread1 to have a value of 2 for i1 and for thread2 to have a value of 3 for i1 if thread1 and thread2 have both updated i1 but those updated value has not yet been propagated to "main" memory or other threads.
On the other hand, geti2() effectively accesses the value of i2 from "main" memory. A volatile variable is not allowed to have a local copy of a variable that is different from the value currently held in "main" memory. Effectively, a variable declared volatile must have it's data synchronized across all threads, so that whenever you access or update the variable in any thread, all other threads immediately see the same value. Of course, it is likely that volatile variables have a higher access and update overhead than "plain" variables, since the reason threads can have their own copy of data is for better efficiency.
Well if volatile already synchronizes data across threads, what is synchronized for? Well there are two differences. Firstly synchronized obtains and releases locks on monitors which can force only one thread at a time to execute a code block, if both threads use the same monitor (effectively the same object lock). That's the fairly well known aspect to synchronized. But synchronized also synchronizes memory. In fact synchronized synchronizes the whole of thread memory with "main" memory. So executing geti3() does the following:
this (assuming the monitor is unlocked, otherwise the thread waits until the monitor is unlocked). i3, which may have just been reset from "main" memory). geti3() we have no changes.) this. So where volatile only synchronizes the value of one variable between thread memory and "main" memory, synchronized synchronizes the value of all variables between thread memory and "main" memory, and locks and releases a monitor to boot. Clearly synchronized is likely to have more overhead than volatile.
- 作者: keenonjava 2005年05月22日, 星期日 00:27 回复(4) | 引用(0) 加入博采
普元杯构件技术大赛
- 作者: keenonjava 2005年05月11日, 星期三 21:58 回复(0) | 引用(0) 加入博采
关于String的分割
- 作者: keenonjava 2005年04月19日, 星期二 21:17 回复(0) | 引用(0) 加入博采
java类库的类的实现的源代码从哪里可以找到?
- 作者: keenonjava 2005年04月13日, 星期三 00:28 回复(1) | 引用(0) 加入博采
Java Cup全国大学生信息技术大奖赛 -- 大赛介绍
经过将近10年的发展,Java技术已经遍布世界的各个角落,真正成为一种无处不在的的编程语言。到2004年10月为止,从Sun公司下载Java开发工具的次数已经超过1亿次,有超过6.5亿台PC安装了Java虚拟机,超过3.5亿部移动电话使用了Java技术。更为重要的是,J2EE已经成为企业应用开发实际上的标准,被认为是当今最完整、技术最先进的企业应用平台之一。
开发一个高性能的Java应用,需要开发者同时掌握多方面的知识。一方面,开发者需要对该应用乃至该行业有深入的了解,才能够设计出符合该行业事务逻辑和工作流程的系统。另一方面,开发者需要对Java语言本身都有深入的了解,才能够正确的运用Java语言的种种特性编写出高效的代码来。此外,选择一个功能强大并且得心应手的开发工具,有助于解决开发过程中出现的种种疑难问题,大幅度缩短项目的开发周期。其次,以J2EE应用为例,一个J2EE应用在不同的中间件(应用服务器)上的表现有明显的差异,因此选择一个合适的中间件能够显著提高J2EE应用的性能。在有限的预算限制下,选用何种体系的服务器(包括硬件构架和操作系统),更是影响一个J2EE应用性能的关键因素。可以说,Java应用开发是一个系统工程,需要综合考虑行业特征、Java语言、中间件、操作系统乃至硬件平台等多方面的因素。很遗憾的是,我们注意到大多数的开发者都只能够考虑这其中的一两个因素,导致开发出来的Java应用的性能不高,或者是白白浪费了大量的系统资源。
为了提高中国的Java应用水平,倡导科学的Java开发理念,太阳计算机系统(中国〕有限公司特联合国内多家大学共同举办"Java杯"全国大学生信息技术大奖赛。参赛者要针对一个特定的实际问题提出自己的Java解决方案,并通过实际设计、开发、优化和应用该J2EE来展示自己的技术实力。对参赛方案的评估包括实用型,创新性,伸缩性,系统性能,投入产出比等多方面因素。获奖选手将获得大赛委员会共同颁发的获奖证书和丰厚奖金,获奖作品也将获得被著名 IT 企业评估和购买的机会。
此次大赛分为预赛和决赛两个部分。在预赛阶段,所有中国大专院校的在读学生(包括硕士研究生和博士研究生)均可在本网站注册成为中国大学生Java/Solaris协会会员。为了鼓励团队合作我们要求参赛选手自行组队为本次比赛做好准备,每队的人数限制为2 到4 人。Sun公司会在2005年6 月初向所有注册会员发送比赛章程和预赛题目,参赛队伍有两个星期的时间完成题目并将解决方案按照指定的格式提交给Sun公司。本次大赛命题和评判委员会将在公平和公正的原则下对所有参赛作品进行评估,并从中挑选10到15支队伍(具体数量根据预赛作品的质量决定)进入决赛。Java语言的缔造者James Gosling将亲自参加本次大奖赛决赛部分的评判工作,并评选出获奖作品和团队。获胜队伍将获得大赛组委会颁发的获奖证书和丰厚奖金,由Sun Press出版的原版Java图书和其它纪念品,以及进入Sun中国公司实习乃至成为正式员工的机会。
本次大奖赛设立如下奖励:
一等奖一名:奖金3000美元
二等奖两名:奖金2000美元
三等奖三名:奖金1000美元
为了协助新近学习Java的同学快速掌握相关技术,提高自己的技术水平并在本次大奖赛中取得更好成绩,我们将陆续在"参考资料"栏目发布一些与本次大奖赛相关的信息和教程,请有意参加此次大奖赛的同学经常关注该栏目不断更新的资料。
Sun 公司保留所有对此活动的变更及解释权。请随时登录网站http://www.jug.edu.cn/java_cup/intro.html查询更新信息。
- 作者: keenonjava 2005年04月6日, 星期三 22:13 回复(3) | 引用(0) 加入博采
王庆阳的讲稿和C++与java的区别总结
- 作者: keenonjava 2005年04月6日, 星期三 21:32 回复(0) | 引用(0) 加入博采
The Java Language Specification
http://java.sun.com/docs/books/jls/
The Java Language Specification, Second Edition - Written by the inventors of the technology, this book is the definitive technical reference for the Java programming language. If you want to know the precise meaning of the language's constructs, this is the source for you.
The book provides complete, accurate, and detailed coverage of the syntax and semantics of the Java programming language. It describes all aspects of the language, including the semantics of all types, statements, and expressions, as well as threads and binary compatibility.
James Gosling is a Fellow and Vice President at Sun Microsystems, the creator of the Java programming language, and one of the computer industry's most noted programmers. He is the 1996 recipient of Software Development's "Programming Excellence Award." He previously developed NeWS, Sun's network-extensible window system, and was a principal in the Andrew project at Carnegie Mellon University, where he earned a Ph.D. in Computer Science.
Bill Joy is founder and Vice President of Research at Sun Microsystems, where he has led the company's technical strategy, working on both hardware and software architecture. He is well known as the creator of the Berkeley version of the UNIX operating system, for which he received a lifetime achievement award from the USENIX Association in 1993. He received the ACM Grace Murray Hopper Award in 1986. Joy has had a central role in shaping the Java programming language.
Guy L. Steele Jr. is a Distinguished Engineer at Sun Microsystems, where he is responsible for the specification of the Java programming language as well as research in parallel algorithms. He is well known as the co-creator of the Scheme programming language and for his reference books for the C programming language (with Samuel Harbison) and for the Common Lisp programming language. Steele received the ACM Grace Murray Hopper Award in 1988 and was named an ACM Fellow in 1994.
Gilad Bracha is Computational Theologist at Sun Microsystems, and a researcher in the area of object-oriented programming languages. Prior to joining Sun, he worked on Strongtalk, the Animorphic Smalltalk System. He holds a B.Sc. in Mathematics and Computer Science from Ben Gurion University in Israel and a Ph.D. in Computer Science from the University of Utah.
- 作者: keenonjava 2005年04月6日, 星期三 12:39 回复(2) | 引用(0) 加入博采
第一次沙龙总结
第一次沙龙总结
4月2日晚,一群Java爱好者聚集在网络中心的508室开展了兴趣小组的第一次活动。活动由佘怀化主持,中心的20余名同学参加了沙龙,气氛热烈,收获颇丰。
首先,常丰峰师兄联系中心尤其是R&D室和数据库室的情况:大部分师兄师姐都用Eclipse进行开发,就介绍了一下Eclipse工具的配置,一个简单的程序的编写、调试,都是通过实例进行演示的,形象而生动。还让新手自己动手编一个程序试验一下,而一些用过Eclipse的同学则就使用过程中遇到的问题,提出疑问,得到了满意的答复。
接下来,由04级的王庆阳同学给大家介绍J2SE里的一个很重要的包:Collection包。他显然是经过了精心准备,先介绍了一下包里比较常用的东东,然后通过代码进行了演示,并结合自己在学习中的体会对其发表了的看法:哪些是Collection包中经常用的东西,哪些是在学习中应该尤其注意的,哪些是为了与JDK1.1或JDK1.2版本中的东西兼容才保留下来的,并初步介绍了一下各个类在使用过程中的优缺点。在讲解过程中,不时有人提出问题,大家进行讨论,得到满意的答案后,讲解继续。通过王的介绍,初学者有了一定得了解,知道日后在学相关的内容时该从何处下手,该注意哪些方面;有过接触的同学则有了更深的了解。
最后,大家就C++与Java的区别进行了讨论。在佘怀化同学的引导下,大家就二者的区别进行了详细的讨论。整个讨论过程,也从大的方面入手,然后到详细的细节。虽然可能仍不详尽,但大家都发表了自己的看法,综合起来就有了一个更深刻的了解。
我们组织该沙龙的目的,就是想促进同学们之间的技术交流、活跃同学们之间的学术气氛,互相提高, Brain Storm就是我们的目标。沙龙以后每三周会举行一次,活动前会给大家一个内容介绍。届时也会有我们周围的高手或者请老师或工程师,结合自己的学习经验给大家做个简单的报告;也会针对我们在平时学习JAVA过程中遇到的问题进行讨论。每次活动结束时,会留一个小的"homework":让大家结合介绍的或讨论的内容写一段小的代码,以备作下次讨论的原材料。
我们将尽快将讲稿和讨论的内容发上来。
- 作者: keenonjava 2005年04月4日, 星期一 23:49 回复(2) | 引用(0) 加入博采
针对第一次沙龙的不足和改进进行讨论
- 作者: keenonjava 2005年04月2日, 星期六 23:53 回复(0) | 引用(0) 加入博采