开发者

Dear Java, why do most of the tutorials look as if they are leftovers of the 80's? [closed]

开发者 https://www.devze.com 2023-01-11 09:24 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 12 years ago.

I learnt Java back in university. It's been 4 years since I last coded Java. I develop PHP applic开发者_JAVA技巧ations mainly. This time I need a language with more powerful concurrency support. I thought to myself, I'll just revise my Java in an hour and I'm ready to go.

As it turned out, there is no human friendly tutorials (!!) that can be easily found. I searched "java tutorial" and the first results are either impossibly abstract with no useful code examples or ad-filled spit outs of the Web 1.0 era! More complex searches just led me to more confusing/outdated posts. I just love PHP for the numerous friendly tutorials out there.

Anyway, to avoid making this a pointless post, can anyone direct me to a readable tutorial to how I can use the thread ExecutorService to 1) queue a few thousand Runnables, 2) have a maximum of 15 threads executing at a time, and 3) if a thread fails, re-queue it or just don't remove it from the Executor's pool.

Thank you in advance!


It's from 2006, but still pretty decent: http://math.hws.edu/javanotes/


this should work for you

Executors.newFixedThreadPool(15) 

15 threads fixed, not max. but it's no big deal to have 15 idle threads.

regarding tutorials: good tutorials are very hard to write, and generally there is NO reward.

regarding concurrency: it is very difficult. people spend years just to understand the basics. you shouldn't be surprised if a few hours is needed to understand a concurrency issue.


If you dislike Times New Roman, just change the browser default font to Tahoma or something like.

Dear Java, why do most of the tutorials look as if they are leftovers of the 80's? [closed]

Then start here and click your way through Next link. Then there are the API docs, each with examples in the introductory text. E.g. ExecutorService. Then there are books, like Concurrency in Practice.

0

精彩评论

暂无评论...
验证码 换一张
取 消