If you want your Juno got faster you need to add this toeclipse.ini file:
-vmargs -Xms512m -Xmx1024m
If you want your Juno got faster you need to add this toeclipse.ini file:
-vmargs -Xms512m -Xmx1024m
In String type we have several method valueOf
static String valueOf(boolean b)
static String valueOf(char c)
static String valueOf(char[] data)
static String valueOf(char[] data, int offset
…
The rules below are not guidelines or recommendations, but strict rules. Contributions to Android generally will not be accepted if they do not adhere to these rules.
Not all existing code follows these rules, but all new code is expected …
不应用线程池的缺点
有些开发者图省事,遇到需要多线程处理的地方,直接new Thread(…).start(),对于一般场景是没问题的,但如果是在并发请求很高的情况下,就会有些隐患:
制定执行策略
在每个需要多线程处理的地方,不管并发量有多大,需要考虑线程的执行策略
线程池的类型
不管是通过Executors创建线程池,还是通过Spring来管理,都得清楚知道有哪几种线程池:
其实,这些不同类型的线程池都是通过构建一个ThreadPoolExecutor来完成的,所不同的是corePoolSize,maximumPoolSize,keepAliveTime,unit,workQueue,threadFactory这么几个参数。具体可以参见JDK DOC。
线程池饱和策略
由以上线程池类型可知,除了CachedThreadPool其他线程池都有饱和的可能,当饱和以后就需要相应的策略处理请求线程的任务,ThreadPoolExecutor采取的方式通过队列来存储这些任务,当然会根据池类型不同选择不同的队列,比如FixedThreadPool和SingleThreadExecutor默认采用的是无限长度的LinkedBlockingQueue。但从系统可控性讲,最好的做法是使用定长的ArrayBlockingQueue或有限的LinkedBlockingQueue,并且当达到上限时通过ThreadPoolExecutor.setRejectedExecutionHandler方法设置一个拒绝任务的策略,JDK提供了AbortPolicy、CallerRunsPolicy、DiscardPolicy、DiscardOldestPolicy几种策略,具体差异可见JDK DOC
线程无依赖性
多线程任务设计上尽量使得各任务是独立无依赖的,所谓依赖性可两个方面:
当然,在有些业务里确实需要一定的依赖性,比如调用者需要得到线程完成后结果,传统的Thread是不便完成的,因为run方法无返回值,只能通过一些共享的变量来传递结果,但在Executor框架里可以通过Future和Callable实现需要有返回值的任务,当然线程的异步性导致需要有相应机制来保证调用者能等待任务完成,关于Future和Callable的用法见下面的实例就一目了然了:
(自) Activity,Service属于主线程,在主线程中才能更新UI,如toast等。其他线程中不能直接使用,这时可以使用Handler来处理,Handler可以在Activity和Service中。
关于在非UI线程中进行UI操作会出现问题: Can’t create handler inside thread that has not called Looper.prepare()
这时有两种方式来解决:
(一)在该非UI线程中创建消息队列(因为创建的工作线程默认是没有消息循环和消息队列的),Looper.prepare();…..;Looper.loop();
newThread() {
public void run() {
Looper.prepare(); //创建消息队列
todo();
Looper.loop();//进入消息循环
}}.start();
(二)运用Handler机制:
package com.simon;
import android.app.Activity;
import android.os.Bundle;
import android.os.Message;
import android.util.Log; …
This story appeared on JavaWorld at
http://www.javaworld.com/javatips/jw-javatip10.html
Developers conversant in the event-driven programming model of MS-Windows and the …
我在使用BOOK: Professional Crystal Reports for VS.NET 的时候,经常出错:
…..Assembles不能用。。。。
这里最好的解决办法是,1.重新安装.Net FrameWork,2. Select the Compile tab and click on the “Advanced Compile Options…” button. Find “Target CPU” and set it to x86. Next find “Target Framework” and set it to .NET Framework …
不少时候在页面中为了布局的需要,下拉列表<select>的宽度需要设成比较小的值,这时如果恰巧它包含的选择项<option>的内容比较长,那么超出select宽度的部分将会被截断,如果option显示的内容又比较重要,必须完整地展现出来,或者你是个完美主义者,那这就成了一个不大不小的问题了。
在IE7+、Firefox中,由于支持了<option>的title属性,我们可以想办法给option标记设置title属性(内容可以与显示的值相同或者不同)。如果是已经做好的页面,不想再做太多改动,可以用下面的脚本,自动遍历页面上的所有<select>,给所有的option加上与text相同的title。
1. 机器名和用户名相同不能正确安装Sqlserver 2008R2!
2. .Net4.0要安装Extended
3. Windows firewall 要开放80口(IIS中设置的)
4.Cystal Report客户端要重新安装
5.目录要被IIS_User?NetWork Service共享(Full Control)…