ITeye博客

结交天下热爱技术的朋友。

sprite311 · 共 29 篇文章

[置顶] LinkedBlockingQueue 模拟抢房间座位问题

问题描述: 假设有10个房间,每个房间有5个座位。这些座位可能是空的,也可能坐着人,房间外面有大量 的人等待空位,房间内的人可能随时离开, 因此要不停的扫描房间空位一旦有空的就抢座上去。 博客原文地址 http://sprite311.iteye.com/blog/2033655 解决思路: 1涉及到多线的安全问题,调查到LinkedBlockingQueue 是java.util.concurrent包下的线程安全的阻塞 队列,用之; 2房间里的座位类似生产者的产品; 3 一个队列模拟一个房间,涉及到多个房间使用队列数组来模拟; 4生产者向队列里放数据(人进入房间)使用offer()方法而…

2014-03-19 17:14 · javaee · 评论(1)

ibatis insert 返回自增主键

英文描述:how ibatis return the auto increment primary key when insert. 详细解决办法在这里,我验证过,是可用的: http://snowolf.iteye.com/blog/215571 但是看了解决办法后,我不明白@@IDENTITY 以及 SCOPE_IDENTITY()是什么意思。 所以又搜索了一下: http://stackoverflow.com/questions/481395/t-sql-identity-scope-identity-output-and-other-methods-of-retrieving-la…

2015-01-26 17:35 · javaee · 评论(0)

window清空文件夹脚本 | 清空tomcat下work 、webapp文件夹

清空tomcat下work 、webapp文件夹 文件拓展名为 .bat @echo off echo 删除A下所有文件及文件夹,但保留A文件夹 for /r D:\apache-tomcat-6.0.18-auth_app2.0\work\ %%i in (.) do if /i "%%i"=="D:\apache-tomcat-6.0.18-auth_app2.0\work\." (del/s/q/a "%%i") else rd/s/q "%%i" for /r D:\apache-tomcat-6.0.18-auth_app2.0\webapps\ %%i in (.) do if…

2014-08-20 14:52 · javaee · 评论(0)

中序遍历后序遍历 构建二叉树

/** * Definition for binary tree public class TreeNode { int val; TreeNode left; * TreeNode right; TreeNode(int x) { val = x; } } */ public class Solution { public TreeNode buildTree(int[] inorder, int[] postorder) { if (inorder == null || postorder == null || inorder.length != postorder.length) re…

2014-08-05 16:02 · 数据结构 · 评论(0)

ascII,unicode,utf-8 utf-16,utf-32,BOM 的解说(一) mark

http://blog.csdn.net/fan158/article/details/3729130

2014-03-28 17:53 · mark · 评论(0)

java.util.vector 多线程问题及java.util.concurrent包下并发安全原理

1、vector在所有的方法上都加上了synchronized关键字,这样保证了访问vector对象的任何方法时都必须获取对象锁,所以vector保证了不会被多线程同时访问,但是如果我的某个方法这样写: //vector 是全局变量 public boolean putIfAbsent() { boolean absent = vector.contains(x); if (absent) { vector.add(x); } return absent; } 在contains方法判断为真之后,线程释放锁,这时在add方法被调用之前是有空隙的,其他线程完全有可能获取锁并改变vector的状…

2014-03-26 10:43 · javaee · 评论(0)

java多线程最基础的问题及答案(译)

java多线程最基础的问题 原文(http://java-success.blogspot.com.au/2011/09/java-multi-threading-interview.html) 1、Q:为什么面试官喜欢问多线程的知识? A:因为它不简单,而且如果想写出可拓展、高吞吐的系统它是必备的知识。 2、Q:进程和线程的区别? A:线程是运行在进程内部的,进程可以包含多个线程,线程有时也叫轻量级的进程。 note:JVM是一个进程,运行于其中的线程是共享堆内存的。这就是为什么这些线程可以访问同一个对 象。线程有自己的栈内存。这也是(一个线程的方法调用以及它的局部变量对于其他线程是线程 …

2014-03-05 12:35 · javaee · 评论(0)

java中PriorityQueue优先级队列使用方法 mark

http://blog.csdn.net/hiphopmattshi/article/details/7334487

2014-03-04 17:05 · javaweb · 评论(0)

Array.prototype.slice.call(list) mark

参考答案 http://stackoverflow.com/questions/7056925/how-does-array-prototype-slice-call-work http://stackoverflow.com/questions/5145032/whats-the-use-of-array-prototype-slice-callarray-0 http://www.cnblogs.com/littledu/archive/2012/05/19/2508672.html 研究由来 http://codestar.alloyteam.com/ http://www.yuxia…

2014-02-11 10:24 · javascript · 评论(0)

note

spring下载 http://repo.spring.io/webapp/search/artifact/?0&q=spring-framework 淘宝的github https://github.com/taobao erp&crm安装 http://www.google.com.hk/#newwindow=1&q=Compiere+%E5%AE%89%E8%A3%85&safe=strict linux并发连接数查看 http://itnihao.blog.51cto.com/1741976/830365 数据库间传输数据工具 (ETL工具 Kettle) http://www.it…

2013-11-22 12:00 · 评论(0)

Java之Socket与HTTP区别 mark

http://blog.csdn.net/way_ping_li/article/details/7948315

2013-10-11 14:36 · javase · 评论(0)

继承中的多线程问题。 mark

http://blog.csdn.net/songzheng_741/article/details/7938912 继承中的多线程问题。

2013-10-10 12:39 · 评论(0)

zookeeper mark

Zookeeper 从设计模式角度来看,是一个基于观察者模式设计的分布式服务管理框架,它负责存储和管理大家都关心的数据,然后接受观察者的注册,一旦这些数据的状态发生变化,Zookeeper 就将负责通知已经在 Zookeeper 上注册的那些观察者做出相应的反应,从而实现集群中类似 Master/Slave 管理模式 https://www.ibm.com/developerworks/cn/opensource/os-cn-zookeeper/ 应用其一分布式锁的实现

2013-10-09 14:55 · javaweb · 评论(0)

redis的文章 mark

Redis持久化实践及灾难恢复模拟 http://heylinux.com/archives/1932.html Redis经验谈 (高并发) http://www.programmer.com.cn/14577/ redis入门到精通 江南白衣 redis https://github.com/springside/springside4/wiki/Redis

2013-09-24 10:47 · redis · 评论(0)

java concurrent

围绕concurrent的文章很多,多看看对于多线程高并发的解决有好处 http://www.cnblogs.com/aurawing/articles/1887056.html

2013-09-22 16:17 · javaweb · 评论(0)