马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册
x
本帖最后由 wangbo 于 6-8-2014 19:31 编辑
邮件里发过来让你做的,主要写解决问题的思路
给应聘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); }
|