码迷,mamicode.com
首页 >  
搜索关键字:num lock    ( 23499个结果
使用lock和condition实现的阻塞队列-字符串
在jdk 的API中提供了一个字符串的阻塞队列 :class BoundedBuffer { final Lock lock = new ReentrantLock(); final Condition notFull = lock.newCondition(); final Con...
分类:其他好文   时间:2014-05-16 05:11:43    阅读次数:323
关于synchronized和lock 的使用及其在线程间的通信
题目要求:子线程循环10次,接着主线程循环100次,接着又回到子线程循环10次,接着再回到主线程又循环100,如此循环50次synchronized的使用import java.util.concurrent.atomic.AtomicInteger;public class Traditional...
分类:编程语言   时间:2014-05-16 04:54:15    阅读次数:312
boost::interprocess(1)
发送端:#include #include #include using namespace std;#include #include #include using namespace boost::interprocess;int num = 0;mapped_region *mp_r;void...
分类:其他好文   时间:2014-05-15 16:05:06    阅读次数:258
12周 项目2 老师兼干部类
#include #include using namespace std; class Teacher { public: Teacher(string nam,int ag,char s,string ad,int num,string t) { name=nam; age=ag; sex=s; ...
分类:其他好文   时间:2014-05-15 04:32:56    阅读次数:262
学习C/C++语言:结构体,动态链表
//*************************************************************** //结构体:简单的静态链表 #include #include #define NULL 0 #define SIZE 10 struct student { char num[SIZE]; float score; struct student *next; ...
分类:编程语言   时间:2014-05-15 02:55:09    阅读次数:359
leetcode第一刷_Letter Combinations of a Phone Number
水题。数字一共就9个,去掉1是用来显示标点的,剩下8个。 穷举一下map,然后有几个数字,就输出这几个数字的排列,是一个dfs嘛。 map num; void allCombinations(string &digits, int start, int len, string &pres, vector &res){ if(len == digits.length()){ ...
分类:其他好文   时间:2014-05-15 01:42:26    阅读次数:264
Leetcode 线性表 Two Sum
题意:给定一组数和另一个数,在这组数中找两个数,使它们的和等于给定的数 思路1: --> 错,因为题目要求返回下标。 1.排序 2.两个下标,一个指向头,一个指向尾 3.如果下标指向的两个元素相加大于给定的数,尾下标减一 如果小于,头下标加一 思路2: hash 1.用hash存储每个数的下标 2.数组,看hash[target-num[i]]是否存在 复杂度:时间O(n), 空间O(n)...
分类:其他好文   时间:2014-05-15 01:28:13    阅读次数:297
java数字字符串累加1的解决方案
近期操作项目遇到这样的问题,研究了下搞出了一个解决方案.//num也可以是在数字字符串里面截取的,比如我有14位的数字字符串前六位是市级,7,8位代表县区,后两位代表乡镇,最后四位是累计+1的,这个时候你就可以根据前10位查出最大的是多少,然后用最大的+1得出新的最大的..//你要+1的字符串Str...
分类:编程语言   时间:2014-05-14 23:03:10    阅读次数:645
python经典算法
# 非波拉锲数列def fibs(num): the_list=[] a,b,i=0,1,1 for i in range(num-1): a,b=b,a+b print bfibs(10)
分类:编程语言   时间:2014-05-14 22:00:27    阅读次数:290
并发编程实践五:ReentrantLock
ReentrantLock是一个可重入的互斥锁,实现了接口Lock,和synchronized相比,它们提供了相同的功能,但ReentrantLock使用更灵活,功能更强大,也更复杂。这篇文章将为你介绍ReentrantLock,以及它的实现机制。 ReentrantLock介绍 通常,ReentrantLock按下面的方式使用: public class ReentrantLockTest...
分类:其他好文   时间:2014-05-14 20:02:26    阅读次数:397
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!