|
邮件里发过来让你做的,主要写解决问题的思路
给应聘Java developer的人参考
Techinterview questions - “homework”
Thefollowing items should be completed in Java 1.7 without relying on otherframeworks. The code should be production ready. Make reasonable assumptions ifany information is missing.
Ifneeded, make notes explaining the assumptions. Please don’t send binaries.Ideally your code can be compiled with Maven.
1.,
Implementan in-memory cache. What we know about the use case:
- TheTTL of the items is fairly short (~10 seconds)
- Thesystem has plenty of memory
- Thekeys are widely distributed across the keyspace
- Eachitem may or may not be accessed during the TTL
- Eachitem might be accessed multiple times during the TTL
2.,
Createa simple framework where work items can be submitted. Each work item is aninstance of a class and the definition of “parallelism”, which controls howmany threads are created to execute the work item.
Theframework makes sure that the number of threads executing the work item shouldremain the same until the threads finished executing the work item, eg.: if thework item dies, the framework should restart it.
Thereis no need to cater for timeouts.
Sampleinterfaces for the framework:
publicinterface WorkItemExecutor
{
void executeWorkItem(WorkItem w, intparallelism);
}
publicinterface WorkItemCompletionCallback
{
void complete();
}
publicinterface WorkItem
{
void execute(WorkItemCompletionCallbackcallback);
} |
上一篇:Rebate Reconciliation下一篇:【求职】Software Testing登陆3个月求职未果,求内部推荐
|