Goodspeed

导航

11 2014 档案

Tomcat启动脚本
摘要:start.sh#!/bin/shJAVA_HOME="/root/app/jdk1.8.0_25"CATALINA_BASE="/root/app/apache-tomcat-8.0.15"CATALINA_HOME="/root/app/apache-tomcat-8.0.15"JRE_HOME... 阅读全文

posted @ 2014-11-26 14:32 Goodspeed 阅读(2220) 评论(0) 推荐(0) 编辑

Task中的异常处理
摘要:最简单的方式 var t = new Task(() => { throw new Exception("unknow excption"); }); t.Start(); try ... 阅读全文

posted @ 2014-11-02 21:16 Goodspeed 阅读(1900) 评论(0) 推荐(0) 编辑

Parallel的陷阱
摘要:var nums = Enumerable.Range(1,4).ToArray(); int total = 0; Parallel.For( fromInclusive: 0, toExclu... 阅读全文

posted @ 2014-11-02 12:44 Goodspeed 阅读(367) 评论(0) 推荐(0) 编辑

用Task代替TheadPool
摘要:TheadPool的问题不支持线程的取消、完成、失败通知等交互性操作不支持线程执行先后次序using System;using System.Diagnostics;using System.Threading;using System.Threading.Tasks;namespace Conso... 阅读全文

posted @ 2014-11-02 10:52 Goodspeed 阅读(510) 评论(0) 推荐(0) 编辑

使用ThreadPool代替Thread
摘要:线程的空间开销线程内核对象。包含上下文信息。32位系统占用700字节线程环境块。包括线程的异常处理链。32位系统占用4KB用户模式栈。保存方法的参数、局部变量和返回值内核模式栈。调用操作系统的内核模式函数时,系统会将函数参数从用户模式栈复制到内核模式栈。32位系统占用12KB线程的时间开销创建时,系... 阅读全文

posted @ 2014-11-02 10:29 Goodspeed 阅读(659) 评论(0) 推荐(0) 编辑

正确停止线程
摘要:using System;using System.Threading;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { va... 阅读全文

posted @ 2014-11-02 10:02 Goodspeed 阅读(533) 评论(0) 推荐(0) 编辑

线程同步中使用信号量AutoResetEvent
摘要:using System;using System.Threading;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { va... 阅读全文

posted @ 2014-11-02 09:54 Goodspeed 阅读(362) 评论(0) 推荐(0) 编辑

异步和多线程的区别
摘要:多线程会有一个工作线程,占用更多的CPU。异步将使用DMA模式的IO操作using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Net;using System.Text... 阅读全文

posted @ 2014-11-02 09:26 Goodspeed 阅读(917) 评论(0) 推荐(0) 编辑