净谦

导航

2012年3月19日 #

克隆模式-深浅克隆

摘要: package create.clone;import java.io.ByteArrayInputStream;import java.io.ByteArrayOutputStream;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;/*** 简单形式,深浅克隆* * 适用于需要创建的原型对象数目较少且比较固定的情况,原型对象的保存交由客户端负责* @author zhangchy**/// 作为成员变量的A要序列化class A implements 阅读全文

posted @ 2012-03-19 10:10 康安V 阅读(368) 评论(0) 推荐(0)

2012年3月18日 #

SharedResourceLeadToDataError

摘要: using System;using System.Collections.Generic;using System.Text;using System.Threading;namespace SharedResourceLeadToDataError{ class Program { static void Main(string[] args) { Thread[] ths = new Thread[4]; for (int i = 0; i < 4; i++) { ths[i] = new Thread(increaseCoun... 阅读全文

posted @ 2012-03-18 13:30 康安V 阅读(144) 评论(0) 推荐(0)

SharedResource Lead To Deadlock sample[转自: Net4.0面向对象编程漫谈(应用篇)]

摘要: using System;using System.Collections.Generic;using System.Text;using System.Threading;namespace SharedResourceLeadToDeadlock{ class Program { //共享资源 static SharedResource R1 = new SharedResource(); static SharedResource R2 = new SharedResource(); static void Main(string[] args) { Thread th1 = new . 阅读全文

posted @ 2012-03-18 13:11 康安V 阅读(134) 评论(0) 推荐(0)

Join Lead to DeadLock sample[转自: Net4.0面向对象编程漫谈(应用篇)]

摘要: using System;using System.Collections.Generic;using System.Text;using System.Threading;namespace JoinLeadToDeadlock{ class Program { static Thread mainThread; static void Main(string[] args) { Console.WriteLine("主线程开始运行"); mainThread = Thread.CurrentThread; Thread ta = new Thread(new Threa 阅读全文

posted @ 2012-03-18 13:01 康安V 阅读(141) 评论(0) 推荐(0)

进程与进程间通讯[转自: Net4.0面向对象编程漫谈(应用篇)]

摘要: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Diagnostics;using System.IO;namespace ProcessInfo{ public partial class frmStartNewProcess : Form { public frmStartNewProcess() { 阅读全文

posted @ 2012-03-18 00:18 康安V 阅读(213) 评论(0) 推荐(0)

2012年3月15日 #

异步模式下的超时处理

摘要: using System;using System.Net;using System.IO;using System.Text;using System.Threading;public class RequestState{ // This class stores the State of the request. const int BUFFER_SIZE = 1024; public StringBuilder requestData; public byte[] BufferRead; public HttpWebRequest request; public HttpWebResp 阅读全文

posted @ 2012-03-15 10:58 康安V 阅读(728) 评论(0) 推荐(0)

中介者模式

摘要: package behaviroal.media;/*** 中介者模式* * 中介者知道所有的同事对象,MVC中的控制器*优点*避免同事对象之间的过度耦合,使得中介类和同事类可以相对独立演化*将对象的行为和协作抽象化,把对象的行为与其他对象的相互作用分开处理*缺点*降低了同事对象的复杂性,代价是增加了中介者的复杂性,在很多情况下并不一定更好*中介者类中充满了各个具体同事类的关系协调代码,这些代码经常是不能复用的,同事类的复用是以中介者的不可复用为代价* * @author zhangchy**/class Japanese{public void export(){System.out.pri 阅读全文

posted @ 2012-03-15 10:35 康安V 阅读(140) 评论(0) 推荐(0)

跌代器模式

摘要: package behaviroal.iterator;import java.util.List;import java.util.Vector;/*** 跌代器模式* 迭代器具备一个遍历接口,集合的接口就不必具备遍历接口,简化了集合* 每一个集合对象都可以有很多不同的迭代器,这些迭代器彼此独立* 遍历的算法封装在迭代器里,因此迭代的算法可以独立于集合单独变化* * 可以顺序地访问一个集合中的元素而不必暴露集合中的内部表象* @author zhangchy**/interface IAggregrate{ public Iterator createIterator();}class Cr 阅读全文

posted @ 2012-03-15 10:32 康安V 阅读(218) 评论(0) 推荐(0)

责任链模式

摘要: package behaviroal.chain;/*** 责任链模式 * * 感觉就是单向链表* 避免请求发送者与接受者耦合在一起,让多个对象连接成一条链,* 并且沿着这条链传递请求,直到有对象处理他为止* @author zhangchy**降低了发出请求的对象和处理请求对象之间的耦合。* 允许多于一个的处理者对象根据自己的逻辑来决定哪一个处理者最终处理这个请求* 发出命令的请求只是把请求传给链结构的初始者,而不需要知道哪一个节点处理了这个请求* */class Task{private String type;public String getType() {return type;}p 阅读全文

posted @ 2012-03-15 10:29 康安V 阅读(115) 评论(0) 推荐(0)

VSTS 2008, Web Tests and using Fiddler

摘要: I have been doing some performance and load testing of a web application I have been working on lately. Most of my previous experience was with the 2005 flavour of VSTS and I was keen to play with the 2008 version to see what improvements have been made. This web application is quite heavy in terms 阅读全文

posted @ 2012-03-15 10:15 康安V 阅读(220) 评论(0) 推荐(0)