问题:如何实现死锁。关键:1 两个线程ta、tb2 两个对象a、b3 ta拥有a的锁,同时在这个锁定的过程中,需要b的锁;tb拥有b的锁,同时在这个锁定的过程中,需要a的锁;关键的实现难点是3, —— 所以说,死锁也不是那么容易出现的吧。。实现方式synchronized、Lock 等等死锁例子1采...
分类:
编程语言 时间:
2014-07-15 23:23:36
阅读次数:
374
这一块主要是讨论关于进程同步的相关问题,主要是考虑一下的关键字:锁对象、条件对象 -> synchronized wait() notify()。1、关于锁对象与条件对象: 所对象的定义在java中的java.util.concurrent.locks中Lock接口,具体可以有多种实现。对于l...
分类:
编程语言 时间:
2014-07-14 14:43:05
阅读次数:
360
其实就是一道蛮简单的数位DP考试的时候出了点小错导致基本Wa0还好数据分治有30分- -num[i][j][k]表示前i位数字和为j的数的个数 k=0表示不顶上界 k=1表示顶上界转移方程见代码dp[i][j][k]表示前i位数字和为j的数的和转移方程同见代码 1 #include 2 #incl....
分类:
其他好文 时间:
2014-07-13 23:36:05
阅读次数:
269
本文由该问题引入到内核锁的讨论,归纳例如以下为什么须要内核锁?多核处理器下,会存在多个进程处于内核态的情况,而在内核态下,进程是能够訪问全部内核数据的,因此要对共享数据进行保护,即相互排斥处理有哪些内核锁机制?(1)原子操作atomic_t数据类型,atomic_inc(atomic_t *v)将v...
分类:
其他好文 时间:
2014-07-13 23:31:28
阅读次数:
269
public class Solution { public int longestConsecutive(int[] num) { HashSet hash=new HashSet(); int max=1; for(int n:num) ...
分类:
其他好文 时间:
2014-07-13 21:52:58
阅读次数:
244
点击打开链接
题意:有n层楼层,现在在每一层有两个按钮,分别为up和down,按动按钮时,可以向上或向下跳动num[ i ]层;问能否以最少的次数从A到B层,不能输出-1;
解析:构图,将从i层到按动按钮后跳转的楼层,看作连通状态,赋值为1,这样就转换成单源最短路问题;
#include
#include
#include
using namespace std;
const int m...
分类:
其他好文 时间:
2014-07-13 18:37:00
阅读次数:
231
批量创建用户read-p"请输入用户名的前缀:"userread-p"请输入用户的数目:"numcount=0if(($num>10))thenecho"最多只能同时新建10个用户"elseforiin$(seq$num)doifuseradd$user$ithencount=$(($count+1))echo"用户$user$i已经创建成功"fidoneecho"一共新建的用户数:$count个"fi..
分类:
其他好文 时间:
2014-07-13 14:26:38
阅读次数:
230
代码:
#include
#include
#include
#include
int main()
{
int num[100];
int odd = 0, even = 0;
std::string str;
getline(std::cin, str);
std::stringstream s(str);
int j = 0;
while(getline(s, s...
分类:
其他好文 时间:
2014-07-13 13:54:31
阅读次数:
280
题意:求0-B的满足
思路:数位DP,记忆化搜索
#include
#include
#include
#include
using namespace std;
int A, B;
int dp[20][200000];
int bit[20];
int dfs(int cur, int num, int flag) {
if (cur == -1)
return num ...
分类:
其他好文 时间:
2014-07-13 00:02:35
阅读次数:
338
动态链表的建立,输出,删除,插入
#include
#include
#include
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
long num;
float score;
struct student*next;
};
int n;/*n为全...
分类:
其他好文 时间:
2014-07-12 23:23:33
阅读次数:
183