java - Transforming code to multithread version -
i have following problem:
- for example, have 10 lists, each 1 has link other lists, create code search elements in theses lists, i've done algorithm sequentially, start search in first list, if search failed, send messages searching in lists have link (to first one), @ end of algorithm, show results number of lists visited , if find element or no.
- now, want transform parallel algorithm, @ least concurrent 1 using multi-threads:
- to use threads searching;
- to start search in 10 lists @ same time;
as long don't change anything, can consider search read only. in case, don't need synchronization. if want have fast search, don't use threads directly use runnables , appropriate classes. if work directly threads, make sure don't exceed number of processors.
before going further, read multi-threading. mention "java concurrency in practice" (rather safe) recommendation. it's easy wrong.
Comments
Post a Comment