多线程是一把双刃剑,不要盲目使用多线程!
使用多线程的优点:
1、支持并发
2、提高程序执行效率,这里又可以分为两种情况:
单线程情况下,I/O操作让CPU处于"等待"状态,多线程能更好利用CPU;
多核CPU的出现,让多线程程序有更好的执行效率。
缺点:
1、造成一定的线程切换开销
2、资源容易出现竞争,甚至死锁
3、多个线程"同时"对某块内存进行读写,容易造成数据错乱...
分类:
其他 时间:
2014-02-08 09:37:52
收藏:
0 评论:
0 赞:
0 阅读:
384
Problem Description
FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.
The warehouse has N rooms. The i-th room con...
分类:
其他 时间:
2014-02-08 09:56:12
收藏:
0 评论:
0 赞:
0 阅读:
355
寒假学习 第18天 (linux 高级编程) 笔记 总结
一、信号
3.信号的应用(实现多任务)
使用定时器实现多任务
例子:同时显示随机数与时间
#include
#include
#include
#include
#include
#include
WINDOW *wtime,*wnumb;
void showtime(int s)
{
time_t t;...
分类:
其他 时间:
2014-02-08 09:37:02
收藏:
0 评论:
0 赞:
0 阅读:
366
#!/bin/bash
#echo "$# $0 $1 $2"
HH=$HADOOP_HOME/share/hadoop
if [ $# -lt 1 ];then
echo "usage: test.sh source.java [InputFile] [OutputFile]"
exit 0
elif [ ${1##*.} != "java" ];then
e...
分类:
其他 时间:
2014-02-08 09:44:32
收藏:
0 评论:
0 赞:
0 阅读:
409
直方图(Histogram)又称柱状图、质量分布图。是一种统计报告图,由一系列高度不等的纵向条纹或线段表示数据分布的情况。容易的看出如长度、重量、时间、硬度等计量什的数据之分配情形,所用来表示的图形。一般用横轴表示数据类型,纵轴表示分布情况。
直方图是将所收集的测定值或数据之全距分为几个相等的区间作为横轴,并将各区间内之测定值所出现次数累积而成的面积,用柱子排起来的图形,故我们亦称之为柱状图。
...
分类:
其他 时间:
2014-02-08 09:38:42
收藏:
0 评论:
0 赞:
0 阅读:
399
编辑距离是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。
设dp[i][j]表示str1的0到i位置的子串转换成str2的0到j位置的子串所需的最小编辑距离,则有
dp[i, j] := minimum(
dp[i-1, j] + 1, //在str1上i位置删除字符(或者在str2上j-1位置插...
分类:
其他 时间:
2014-02-08 09:32:02
收藏:
0 评论:
0 赞:
0 阅读:
371
John
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 2412 Accepted Submission(s): 1303
Problem Description
Little John is playing ve...
分类:
其他 时间:
2014-02-08 09:40:22
收藏:
0 评论:
0 赞:
0 阅读:
339
目录:
【C#小知识】C#中一些易混淆概念总结--------数据类型存储位置,方法调用,out和ref参数的使用
【C#小知识】C#中一些易混淆概念总结(二)--------构造函数,this关键字,部分类,枚举
【C#小知识】C#中一些易混淆概念总结(三)--------结构,GC回收,静态成员,静态类
【C#小知识】C#中一些易混淆概念总结...
分类:
其他 时间:
2014-02-08 09:49:32
收藏:
0 评论:
0 赞:
0 阅读:
372
D. Beautiful numbers
time limit per test
4 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Volodya is an odd boy and his taste is strange a...
分类:
其他 时间:
2014-02-08 09:47:02
收藏:
0 评论:
0 赞:
0 阅读:
428
Exact cover
Time Limit:15000MS
Memory Limit:131072KB
64bit IO Format:%lld & %llu
[Submit] [Go Back] [Status]
Description
There is an N*M matrix with only 0s and 1...
分类:
其他 时间:
2014-02-08 09:39:32
收藏:
0 评论:
0 赞:
0 阅读:
395
我想借助沟通模型强调一件事,一件很容易被众人遗忘的一件事。发送方:有责任发送清晰、完整的信息,以便接收方正确接收;也有责任确认信息已被正确理解。接收方:有责任完整地接收信息,正确理解信息,并及时确认收到和理解信息。
分类:
其他 时间:
2014-02-08 09:43:42
收藏:
0 评论:
0 赞:
0 阅读:
333
Given two integers n and k, return all possible
combinations of k numbers out of 1 ... n.For example, If n = 4 and k = 2, a
solution is: [ [2,4], [3,4...
分类:
其他 时间:
2014-02-08 09:31:12
收藏:
0 评论:
0 赞:
0 阅读:
325
背景这几天手上有个活,解析xml,众所周知xml的解析方法有:DOMSAXlinq to
xmlplinq测试用xml和生成代码 1 static void CreateFile() 2 { 3 int N = 5000000; 4 Random
rand = new Random(); 5 usi...
分类:
其他 时间:
2014-02-08 09:29:32
收藏:
0 评论:
0 赞:
0 阅读:
450
You are given annxn2D matrix representing an
image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this
in-place? 1 public class Sol...
分类:
其他 时间:
2014-02-08 09:22:02
收藏:
0 评论:
0 赞:
0 阅读:
338
Given a collection of numbers that might
contain duplicates, return all possible unique permutations.For
example,[1,1,2]have the following unique perm...
分类:
其他 时间:
2014-02-08 09:21:12
收藏:
0 评论:
0 赞:
0 阅读:
313
Write an efficient algorithm that searches for
a value in anmxnmatrix. This matrix has the following properties:Integers in
each row are sorted from l...
分类:
其他 时间:
2014-02-08 09:19:32
收藏:
0 评论:
0 赞:
0 阅读:
327
Given a linked list, determine if it has a
cycle in
it.想了好半天没想出来,后来看网上的做法。用快慢两个指针,慢指针每次移动一位,快指针每次移动两位。如果存在环的话,两个指针一定会相遇。最差的情况是,在慢指针进入环的时候,快指针恰巧在慢指针前面一...
分类:
其他 时间:
2014-02-08 09:20:22
收藏:
0 评论:
0 赞:
0 阅读:
345
Sharepoint学习笔记—习题系列--70-573习题解析 -(Q133-Q135)
分类:
其他 时间:
2014-02-08 09:18:42
收藏:
0 评论:
0 赞:
0 阅读:
350
C#集合基础与运用转至:http://www.cnblogs.com/LiZhiW/p/3539839.html1.集合接口与集合类型(1)集合的命名空间大多数集合类都可以在
System.Collections 和 System.Collections.Generic 名称空间中找到。泛型集合位于...
分类:
其他 时间:
2014-02-08 09:17:02
收藏:
0 评论:
0 赞:
0 阅读:
345
Given a sorted array and a target value, return
the index if the target is found. If not, return the index where it would be if
it were inserted in or...
分类:
其他 时间:
2014-02-08 09:17:52
收藏:
0 评论:
0 赞:
0 阅读:
367