上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页
依赖关系public class Animal{ public Metabolism(Oxygen o, Water w){ //动物新陈代谢,依靠空气和水 }} 合成/组合关系:class Bird{ private Wing wing; //鸟儿必须有翅膀 public Bird() { this.wing = new Wing(); } //出生时,就必须有翅膀}“强”拥有关系,严格的局部与整体关系。 聚合关系:class WideGooseAggregate{ // 大雁群 private WideGoose[] arrayWideGoose;}“弱”拥有关系 关联关系:class P Read More
posted @ 2012-05-27 20:38 技术草根女 Views(263) Comments(0) Diggs(0) Edit
ERROR,一般由虚拟机抛出,例如OOM、系统中的内部错误以及资源耗尽的情形。这种情形程序员不用抛,想抛也抛不了。。 Exception,是所有异常的大爷(父类),这里我将他简单的划分为:RuntimeException和non-RuntimeException。(前者称为unchecked异常,后者称为checked异常) RuntimeException体系,一般都是程序员的错。例如,错误的类型转换、数组越界访问和试图访问空指针等等。这种异常,不catch的话,eclipse不会报错,异常会一直往上抛,直到线程停掉。用于调试,挺好的。当然也可以catch,进行些处理。无视自己已经酿成的错. Read More
posted @ 2012-05-27 16:37 技术草根女 Views(318) Comments(0) Diggs(0) Edit
ThreadPoolExecutor定义public ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threa... Read More
posted @ 2012-05-27 14:10 技术草根女 Views(492) Comments(0) Diggs(1) Edit
我的理解~~【信号量】:用于控制对某资源访问的同一时间的并发量。【如何获取】:semaphore.tryAcquire(),尝试获取,不阻塞semaphore.acquire(),没信号量可用时,将进行阻塞等【如何释放】:semaphore.release();线程抛出各种异常,都别忘了在finally中释放信号量;如果释放的比获取的信号量还多,例如获取了2个,释放了5次,那么当前信号量就动态的增加为5了,要注意。【动态增加】:多释放几次,就可以达到信号量动态增加的效果了【动态减小】:信号量本来有这个api的,不过是protected方法,所以我们需要显式继续Semaphore,并重新实现该a Read More
posted @ 2012-05-25 21:09 技术草根女 Views(9750) Comments(0) Diggs(2) Edit
基本原则:隔离:这是初衷,也是单元测试的根本要求Just Enough:够就行了,别少,但也别多Interaction-based:与之相对的,Stub是state-basedExpection:事先总有期待,期待方法有没有被调用,期待适当的参数,期待调用的次数,甚至期待mock间调用顺序没考虑复用:依赖暴露无遗,尽现测试代码当中:基本语法:Step1. record阶段,记录对若干依赖对象的期望o= EasyMock.createMock(MyAdd.class); //创建Mock对象EasyMock.expect(o.add(1,1)).andReturn(2); //对mock对象,. Read More
posted @ 2012-05-21 23:15 技术草根女 Views(6558) Comments(0) Diggs(2) Edit
File file = new File("C:/huhuhu.txt"); FileInputStream in = new FileInputStream(file); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String line = null; line = br.readLine(); int i=1; String header = "rcvNotify -i "; File file2 = new File("C:/output.tx.. Read More
posted @ 2012-05-21 17:08 技术草根女 Views(1078) Comments(0) Diggs(0) Edit
1. PROPAGATION_REQUIRED -- 支持当前事务,如果当前没有事务,就新建一个事务。这是最常见的选择。 2. PROPAGATION_SUPPORTS -- 支持当前事务,如果当前没有事务,就以非事务方式执行。 3. PROPAGATION_MANDATORY -- 支持当前事务,如果当前没有事务,就抛出异常。 4. PROPAGATION_REQUIRES_NEW -- 新建事务,如果当前存在事务,把当前事务挂起。 5. PROPAGATION_NOT_SUPPORTED -- 以非事务方式执行操作,如果当前存在事务,就把当前事务挂起。 ... Read More
posted @ 2012-05-20 15:33 技术草根女 Views(520) Comments(0) Diggs(1) Edit
简单,又不简单,看看便知道。建议采用demo-4。demo-1 懒汉式(synchronized)/**public class Singleton {/*** 定义一个变量来存储创建好的类实例*/private static Singleton uniqueInstance = null;/*** 私有化构造方法,好在内部控制创建实例的数目*/private Singleton(){//}/*** 定义一个方法来为客户端提供类实例* @return 一个Singleton的实例*/public static synchronized Singleton getInstance(){//判断存 Read More
posted @ 2012-05-20 13:10 技术草根女 Views(8508) Comments(1) Diggs(0) Edit
public class StoreUtils { /** * 绝对偏移量->文件名. * * * @param offset 偏移量 * @return 文件名 */ public static String nameFromOffset(final long offset) { final NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumIntegerDigits(20); nf.setMax... Read More
posted @ 2012-05-18 22:41 技术草根女 Views(1444) Comments(0) Diggs(0) Edit
方式一:方式二:方式三:方式N:好可爱的demo:document.xml文件内容如下:<?xml version="1.0" encoding="UTF-8"?> <node> <key1> value1</ key1> < key2> value 2</ key2> < key3> value 3</ key3> </node>public class ParseXml { public static Map<String, String Read More
posted @ 2012-05-13 23:32 技术草根女 Views(301) Comments(1) Diggs(0) Edit
上一页 1 ··· 4 5 6 7 8 9 10 11 12 下一页