在Java API里已经解释了这个ConcurrentModificationException异常的来历:
当方法检测到对象的并发修改,但不允许这种修改时,抛出此异常。
例如,某个线程在 Collection 上进行迭代时,通常不允许另一个线程修改该 Collection。通常在这些情况下,迭代的结果是不明确的。如果检测到这种行为,一些迭代器实现(包括 JRE 提供的所有通用 collection 实现)可能选择抛出此异常。执行该操作的迭代器称为快速失败 迭代器,因为迭代器很快就完全失败,而不会冒着在将来某个时间任意发生不确定行为的风险。
注意,此异常不会始终指出对象已经由不同 线程并发修改。如果单线程发出违反对象协定的方法调用序列,则该对象可能抛出此异常。例如,如果线程使用快速失败迭代器在 collection 上迭代时直接修改该 collection,则迭代器将抛出此异常。
注意,迭代器的fail-fast快速失败行为无法得到保证,因为一般来说,不可能对是否出现不同步并发修改做出任何硬性保证。快速失败操作会尽最大努力抛出 ConcurrentModificationException。因此,为提高此类操作的正确性而编写一个依赖于此异常的程序是错误的做法,正确做法是:ConcurrentModificationException 应该仅用于检测 bug。
Iterator 是工作在一个独立的线程中,并且拥有一个 mutex 锁。 Iterator 被创建之后会建立一个指向原来对象的单链索引表,当原来的对象数量发生变化时,这个索引表的内容不会同步改变,所以当索引指针往后移动的时候就找不到要迭 代的对象,所以按照 fail-fast 原则 Iterator 会马上抛出 java.util.ConcurrentModificationException 异常。
所以 Iterator 在工作的时候是不允许被迭代的对象被改变的。但你可以使用 Iterator 本身的方法 remove() 来删除对象, Iterator.remove() 方法会在删除当前迭代对象的同时维护索引的一致性。
有意思的是如果你的 Collection / Map 对象实际只有一个元素的时候, ConcurrentModificationException 异常并不会被抛出。这也就是为什么在 javadoc 里面指出: it would be wrong to write a program that depended on this exception for its correctness: ConcurrentModificationException should be used only to detect bugs.
下面的代码没有问题:
- import java.util.*;
- public class TryIteratorRemove {
- public static void main(String [] args){
- Collection<String> myCollection = new ArrayList<String>(10);
- myCollection.add("123");
- myCollection.add("456");
- myCollection.add("789");
- int i=0;
- for(Iterator it = myCollection.iterator();it.hasNext();) {
- String myObject = (String)it.next();
- System.out.println(myObject);
- i++;
- if(i==1){
- //myCollection.remove(myObject); //这行代码有问题,会抛出ConcurrentModificationException
- it.remove();
- }
- }
- System.out.println("After remove,the size of myCollection is: " +
- myCollection.size()+" \n and its content is: ");
- for(String s : myCollection){
- System.out.println(s);
- }
- }
- }
- InfoQ: Grails做足功夫 全力迈向1.0版
- 让Thunderbird成为GTD工具 at live@haliluya
- Solidot | 用Gmail做GTD管理
- 100_Linux_Tips_And_Tricks
- 开发技术以及IT书籍
- Javascript Graphical / Virtual Keyboard Interface
- JavaScript Virtual Keyboard (Study)
- Abhi On Java: Using Quartz Scheduler in a cluster
- Tools for Getting Things Done - Getting Things Done Wiki
- Tools for GTD (Getting Things Done)
- 七大搜索引擎博客搜索的博客提交入口网址 - 菠菜博
- Web 领域25个最有影响力的人(上) , huffington,bezos,创办,创业,领域,baker,ballmer,投资,ceo,微软, , - CSDN 新闻
- InfoQ: 好的测试应该具备哪些特质?
- hipergate :. Free Open Source CRM Groupware and Intranet Software
- RUP与Scrum的对话
- B-Trees
- jdbm开源文件数据库在全文检索中的使用 - gdsean的专栏 - CSDNBlog
- API: treeview YAHOO.widget.TextNode (YUI Library)
- yui tree组件 API
- 2008年(第五届)《世界品牌500强》排行榜
- 2008年《世界品牌500强》排行榜 名单
- The ultimate jQuery Plugin List | Kollermedia.at
- jquery插件
- Aptana Studio | Aptana
虽然在Quartz上有配置Quartz集群Clustering ,但是在Spring中使用Quartz任务调度并支持集群系统却有些问题,下面介绍解决办法:
sudo apt-get update && sudo apt-get dist-upgrade
apt-get install libc6-dev
$ apt-get install libc6-dev g++ gcc
On Fedora:
$ locate crt1.o
/usr/lib/crt1.o
Tapestry5必须有一个"module builder class",很典型地,经常是叫"AppModule",AppModule经常用来定义一些新服务、覆盖原始服务、或者为服务更改配置。常用的是让Tapestry5支持UTF-8的request Encoding、忽略一些路径过滤来支持Servlet和其他Servlet Filter的开发等。下面的代码可以加在AppModule中:
Tapestry5通过在web.xml下定义tapestry.app-package指向的Java包里寻找AppModule,也就是<filter-name>加上"Module"字符。
下面是官方文档里Tapsetry IoC 配置:
Tapestry IoC Configuration
Most other configuration occurs inside your application's module builder class. The application module builder will often define new services, provide overrides of services, or make contributions to service configurations.
Tapestry looks for a module builder class in the services package (under the root package). It capitalizes the <filter-name> and appends "Module". In the previous example, the module builder class would be org.example.myapp.services.AppModule.
If such a class exists, it is added to the IoC Registry. It is not an error for your application to not have a module, though any non-trivial application will have a module.
- Google Code - tapestry5
- tapestry5代码
- Tapestry5HowToCreatePieChartsInAPage - Tapestry Wiki
- Tapestry5创建动态jfreechart图表
- Tapestry5HowToCreateADynamicPDF - Tapestry Wiki
- Tapestry5动态创建下载PDF文件
- Tapestry5HowToStreamAnExistingBinaryFile - Tapestry Wiki
- Tapestry5使用StreamResponse下载文件
- extjs2+tapestry5.11+spring+hibernate(grid,paging.. ....) - Ext JS Forums
- Tapestry Core - Configuring Tapestry
- Ignored Paths,配置Tapestry5忽略某URL PATH路径,支持Servlet开发
- 敏捷质疑: TDD - 切尔斯基 - BlogJava
- Maven -eXtremeComponents
- InterLDAP - Wiki - Main - Tapestry5HowToAcegiCas
- Tapestry5AcegiNoAnnotations - Tapestry Wiki
- Tapestry5Acegi - Tapestry Wiki
- Tapestry5LinkingToNonTapestryURIs - Tapestry Wiki
- Tapestry5HowTos - Tapestry Wiki
- 技术的本质是生活 - JavaEye技术网站
- Tapestry5Utf8Encoding - Tapestry Wiki
- InjectService ,Tapestry5使用UTF-8 Encoding
- RIA development using Tapestry 5 and Openlaszlo
在Tapestry5框架里实现下载文件功能,输出非“text/xml”,“text/html”ContentType类型。
注:(默认地,Tapestry5输出text/html,要输出text/xml,需要在Page 类声明前增加注释,@Meta("tapestry.response-content-type=text/xml"))
下面是Tapestry 5文件流请求/响应的代码示例。
- 【原创】Hibernate 和 memcached 的集成问题 -- Java自由人
- hibernate-memcached - Google Code
- spymemcached - Google Code
- memcached client客户端
- Struts 2 - Welcome
- /var/log/mind » Performance Comparison - C++ / Java / Python / Ruby/ Jython / JRuby / Groovy
- 各种语言性能比较
- Enterprise Java Community: Scaling Your Java EE Applications
- Solutoire.com › Flotr Documentation
- javascript生成图表
- extremetable - Google Code
- Tapestry 5 Advanced Components
- PermGen space
- 使用cglib的框架,如hibernate,spring,tapestry,再多次redeploy后都会出现PermGen space问题
- tapestry5-components - Google Code
- YSlow for Firebug
- Web 前端优化最佳实践
- jiffy-web - Google Code
- Web 前端优化最佳实践
- Tapestry 5 Components Test Application
Tapestry5确实可以自动reload page tml模板和page classes,如果你的web.xml的定义是:
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Tapestry Application</display-name>
<context-param>
<param-name>tapestry.app-package</param-name>
<param-value>org.example.myapp</param-value>
</context-param>
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
那么,包org.example.myapp以及子包下面的tml和page class可以自动reload,也就是说,只有在org.example.myapp.pages下面的page classes和在org.example.myapp.components下面的component classes才会自动reload。
On 32bit platform, maximum virtual space is 4G. (2^32)
And on 32bit Windows, 2G space is reserved for OS kernel and another 2G space is reserved for a process.
So the maximum memory space that jvm can use is 2G.
Excluding some native os specific memory, generally the maximum java heap available for "one" java process is around 1500M.
In your case this limit seems to lie between 1.1G ~ 1.5G.