03 2013 档案
摘要: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++: + - * / % ^ & | ~ ...
阅读全文
摘要:面试题很喜欢问的题目。找了一些资料,发现两者只有以下区别: 1.In absence of anaccess-specifierfor a base class, public is assumed when the derived class is declaredstructand privat...
阅读全文
摘要:Java里的Clone, 顾名思义就是克隆一个类的对象。克隆的方法分为浅拷贝(shallow copy)和深拷贝(deep copy)。Clone的默认方法是shallow copy,考虑以下情况: 1. 对象中所有数据域都属于基本类型,并无对其它对象的引用 2. 原始对象和浅拷贝得到的克隆对象所引...
阅读全文
摘要:synchronized提供内部锁的机制,防止其它线程同时进入synchronized的代码块。synchronized由两部分组成:1.锁对象的引用;2.锁保护的代码块。 对锁对象引用的不同,是static synchronized和synchronized最大的区别: 1 public c...
阅读全文
摘要:最近遇到两道题目,均是关于Linux的基础命令的。 1. 如何查找并杀死一个进程: 1 derek@derek-VirtualBox:~$ ps -ef | grep eric2 derek 2097 1 10 10:32 ? 00:00:01 /usr/bin/p...
阅读全文
摘要:CyclicBarrier和CountDownLatch一样,都是关于线程的计数器。 用法略有不同,测试代码如下: 1 public class TestCyclicBarrier { 2 3 private static final int THREAD_NUM = 5; 4 ...
阅读全文
摘要:老赵博客里面的一道题目,以下是个人答案: 1 /** 2 * Besides this,stack could be used to solved it. 3 * @param array 4 * @param begin 5 * @param end ...
阅读全文
摘要:面试期间曾被问到,这里做个简单的总结。 Vector和ArrayList都是List接口的实现类,内部均通过数组实现,适合随机遍历查找,不适合中间插入和删除。 通过Java的源码,可以窥视两者的不同。以add()方法为例: Vector: public synchronized boolean ...
阅读全文
摘要:1. 什么是ThreadLocal ThreadLocal是一个提供线程本地变量(线程局部变量 / thread-local variables)的类。每一个通过set或get方法访问ThreadLocal变量的线程,都会生成独立的,只属于这个线程变量的副本(“every thread that a...
阅读全文

浙公网安备 33010602011771号