摘要: wait(),notify()和notifyAll()都是java.lang.Object的方法: wait():Causes the current thread to wait until another thread invokes the notify() method or the not... 阅读全文
posted @ 2013-08-21 14:24 macemers 阅读(48083) 评论(3) 推荐(11) 编辑
摘要: C++创建对象有两种方式,在栈上创建对象(Objects on the Stack)和在堆上创建对象(Objects on the Heap)。 假设我们有以下的类: 1 #include 2 using std::string; 3 4 class SpreadsheetCell{ 5 ... 阅读全文
posted @ 2013-08-14 16:56 macemers 阅读(11918) 评论(0) 推荐(1) 编辑
摘要: The only operators that can't be overloaded are the operators forscope resolution (::),member selection (.), andmember selection through a pointer to a function(.*).Almost all operators can be overloaded in C++: + - * / % ^ & | ~ ... 阅读全文
posted @ 2013-03-25 14:03 macemers 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 面试题很喜欢问的题目。找了一些资料,发现两者只有以下区别: 1.In absence of anaccess-specifierfor a base class, public is assumed when the derived class is declaredstructand privat... 阅读全文
posted @ 2013-03-25 13:48 macemers 阅读(267) 评论(0) 推荐(0) 编辑
摘要: Java里的Clone, 顾名思义就是克隆一个类的对象。克隆的方法分为浅拷贝(shallow copy)和深拷贝(deep copy)。Clone的默认方法是shallow copy,考虑以下情况: 1. 对象中所有数据域都属于基本类型,并无对其它对象的引用 2. 原始对象和浅拷贝得到的克隆对象所引... 阅读全文
posted @ 2013-03-25 12:21 macemers 阅读(938) 评论(0) 推荐(0) 编辑
摘要: synchronized提供内部锁的机制,防止其它线程同时进入synchronized的代码块。synchronized由两部分组成:1.锁对象的引用;2.锁保护的代码块。 对锁对象引用的不同,是static synchronized和synchronized最大的区别: 1 public c... 阅读全文
posted @ 2013-03-19 17:55 macemers 阅读(9557) 评论(2) 推荐(3) 编辑
摘要: 最近遇到两道题目,均是关于Linux的基础命令的。 1. 如何查找并杀死一个进程: 1 derek@derek-VirtualBox:~$ ps -ef | grep eric2 derek 2097 1 10 10:32 ? 00:00:01 /usr/bin/p... 阅读全文
posted @ 2013-03-13 11:10 macemers 阅读(799) 评论(0) 推荐(0) 编辑
摘要: CyclicBarrier和CountDownLatch一样,都是关于线程的计数器。 用法略有不同,测试代码如下: 1 public class TestCyclicBarrier { 2 3 private static final int THREAD_NUM = 5; 4 ... 阅读全文
posted @ 2013-03-13 10:02 macemers 阅读(24089) 评论(5) 推荐(3) 编辑
摘要: 老赵博客里面的一道题目,以下是个人答案: 1 /** 2 * Besides this,stack could be used to solved it. 3 * @param array 4 * @param begin 5 * @param end ... 阅读全文
posted @ 2013-03-12 23:22 macemers 阅读(286) 评论(0) 推荐(0) 编辑
摘要: 面试期间曾被问到,这里做个简单的总结。 Vector和ArrayList都是List接口的实现类,内部均通过数组实现,适合随机遍历查找,不适合中间插入和删除。 通过Java的源码,可以窥视两者的不同。以add()方法为例: Vector: public synchronized boolean ... 阅读全文
posted @ 2013-03-12 17:48 macemers 阅读(364) 评论(0) 推荐(0) 编辑