Vector涉及到线程安全问题,也许java跳过有线程安全问题的优化
解决方案 »
- struts2标签取map集合?
- 如何实现在生成excel后重定向到b.jsp或刷新b.jsp
- 怎么用JAVA在IE中实现多人聊天?用application?
- jfreechart 问题
- asp 和jsp 混合 可以吗?
- (高分请教!UP有分!!)####如何将数据写入文件(JSP)?急用,在线等待!!
- 【菜鸟提问】jsp 和 asp 能同时运行在Win98下么?
- jwsdk是否是在JAVA虚拟机上运行的?我运行JWSDK时,DOS窗口一闪就没了,怎么回事?
- 有关websphere的使用平台
- textarea 复制粘贴表格
- 为什么我的ServletContext会出错呢?
- 急,给个jb8中解决编辑jsp问题的补丁。谢谢
for(int i=0; i<a.length; ++i)
{
//......
}
或
for(int i=0; i<t/10; ++i)
{
//循环中没有改变t的值
}编译器可以检测出,你再循环中没有改变变量的值,但是没法检测出方法的返回知是否在循环过程中保持不变。所以,对Vector你所说的那种优化是不会出现的。
很遗憾,我测试了VJ的编译器和javac编译器,你举的两个例子没有你想象的那样。也就是说没有任何优化,跟不优化是一样的。我查了JDK Document,在1.3版本中-O选项是不做任何事情的。
http://java.sun.com/j2se/1.3/docs/tooldocs/win32/javac.html
-O
Note: the -O option does nothing in the current implementation of javac and oldjavac.
Optimize code for execution time. Using the -O option may slow down compilation, produce larger class files, and make the program difficult to debug.
Prior to the Java 2 SDK, the -g and -O options of javac could not be used togther. As of the Java 2 SDK, v1.2, you can combine -g and -O, but you may get suprising results, such as missing variables or relocated or missing code. -O no longer automatically turns on -depend or turns off -g.
在1.4版本的doc中我就没有找到-O这个选项
http://java.sun.com/j2se/1.4/docs/tooldocs/win32/javac.html
你说的最有可能了,那些也正是不能看到的部分(编译器自身进行处理),也许它的编译原理是那样的(是不是可以看它的java specification才可以明白呀)
======================"Vector优化是不会出现的"这句最有可能了.