- 博客(12)
- 收藏
- 关注
File Locks
Some scenarios on Windows 1. using a notepad to edit a txt file, at the same time, a java program is using BufferedReader to read it, what it read is the stale content. 2. when a lock is grabbed, tr...
2010-11-13 14:11:30 305
Random sampling
This is an interview question I got. Given an iterator and a sample size, how can you generate a random List. What I was asked to do is to fill this API [code="java"]public static List randonSampleIt...
2010-11-10 03:44:49 253
Swing Timer
Lab mate came by and talked about a feature he needs to update several textfield periodically on a panel. He is monitoring some resources and will generate a file for display every second, so his UI o...
2010-11-10 03:20:05 139
Several approaches to solve deadlock
This is an example from the official concurrency tutorial. [url]http://download.oracle.com/javase/tutorial/essential/concurrency/deadlock.html[/url] The reason for the deadlock here is that there...
2010-11-10 03:10:20 162
原创 转一篇多线程的atomicity, visibility and orderding
[url] http://jeremymanson.blogspot.com/2007/08/atomicity-visibility-and-ordering.html [/url] 另外一篇讲volatile的也值得读 [url]http://jeremymanson.blogspot.com/2007/08/volatile-does-not-mean-atomic.html[/...
2010-10-22 13:40:27 151
原创 Java程序员的特点
有感而发一下看到很多这里的帖子基本的分析都不做 上来就是util包里面现成的类估计对各个基本数据结构的复杂度也不清楚因为不知道内在结构 树更是不会 更有荒唐的要把数据存到数据库查 见到不只一次真是惊为天人。 转个Amazon面试官的帖子,感觉说java的非常贴切 [url]http://sites.google.com/site/steveyegge2/five-essential-phone...
2010-10-22 13:02:35 183
Verify a binary tree
This problem killed me once. the tricky thing is that only judging parent node greater than left child and less than right child is NOT enough. you need to make sure that the right most leave of your ...
2010-10-19 05:20:06 128
Histogram, calculate the largest area
Given a histogram {1, 3, 4, 6, 2, 1, 3}, calculate the largest rectangle area. idea: for every index(post), we are certain that this rectangle starts from index, but when does it end? if the index ...
2010-10-19 05:17:31 154
Java Semaphore
Java introduced Semaphore since 1.5, let's see how we can use it to maintain an order for thread access. Suppose we have the following code: class Foo { public: A(.....); B(.....); } Foo f; ...
2010-10-18 12:34:35 107
Find all pairs of integers that sum to given value
Design an algorithm to find all pairs of integers within an array which sum to a specified value. Solution: say the array is X[], given value is M, the solution I know is to create a map containin...
2010-10-18 12:31:51 180
Compare ArrayList and LinkedList
[list] I'd better write down something before I forget 1. LinkedList is doubly linked, so it takes up more space and cannot hold as many elements as ArrayList. 2. Insertion, ArrayList is faster, in...
2010-10-18 12:25:56 171
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人