|
|
此文章由 wangbo1118 原创或转贴,不代表本站立场和观点,版权归 oursteps.com.au 和作者 wangbo1118 所有!转贴必须注明作者、出处和本声明,并保持内容完整
本帖最后由 wangbo1118 于 2014-8-7 13:29 编辑
邮件里发过来让你做的,主要写解决问题的思路
给应聘Java developer的人参考
Tech interview questions - “homework”
The following items should be completed in Java 1.7 without relying on other frameworks. The code should be production ready. Make reasonable assumptions if any information is missing.
If needed, make notes explaining the assumptions. Please don’t send binaries.Ideally your code can be compiled with Maven.
1.,
Implement an in-memory cache. What we know about the use case:
- The TTL of the items is fairly short (~10 seconds)
- The system has plenty of memory
- The keys are widely distributed across the keyspace
- Each item may or may not be accessed during the TTL
- Each item might be accessed multiple times during the TTL
2.,
Create a simple framework where work items can be submitted. Each work item is an instance of a class and the definition of “parallelism”, which controls how many threads are created to execute the work item.
The framework makes sure that the number of threads executing the work item should remain the same until the threads finished executing the work item, eg.: if the work item dies, the framework should restart it.
There is no need to cater for timeouts.
Sample interfaces for the framework:
public interface WorkItemExecutor
{
void executeWorkItem(WorkItem w, intparallelism);
}
public interface WorkItemCompletionCallback
{
void complete();
}
public interface WorkItem
{
void execute(WorkItemCompletionCallback callback);
} |
评分
-
查看全部评分
|