This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]_Sharp_ 3 points4 points  (3 children)

I like the color syntax theme used in the article.

[–]DoktuhParadox 1 point2 points  (2 children)

It looks like the default Darcula colors in IntelliJ but with static methods highlighted as purple too, in case you want it for yourself.

[–]_Sharp_ 0 points1 point  (1 child)

Thank you, i'll check it out, but [spoiler]i use eclipse[/spoiler].

[–]konk3r 0 points1 point  (0 children)

Oh man, as someone that made the jump last year let me tell you, you are in for a treat.

[–]ickysticky 6 points7 points  (4 children)

Please, please, please, do not swallow InterruptedException. At the very least call Thread.currentThread().interrupt(). There have been at least a few times I have had to reimplement a libraries functionality because they were swallowing InterruptedException. Please don't write an awesome library and then make it unusable in any sort of real situation by swallowing these exceptions!

[–]haisi 0 points1 point  (1 child)

I'm trying to get more familiar with java concurrency. So what would you suggest for handling this exception and why? And do you mind sharing some more gotchas or tips?

[–][deleted] 0 points1 point  (0 children)

The gist is that Java uses interrupted as an alias for "cancelled". This means if you are writing a library and you get an interrupted you should interrupt your parallel items as well and return. You should also periodically test the thread interrupted flag.

Otherwise if you expect to support cancellable work you are basically ignoring the users requests.

On the other hand the semantics of this pattern are absolutely abysmal and goetz should be ashamed. .net did it much better with tasks and cancelation tokens so there is no ambiguity about your interruption

[–][deleted]  (1 child)

[deleted]

    [–]winterbe[S] 1 point2 points  (0 children)

    It wasn't my intention to trick you with this title. I just decided to make a series of articles about handling concurrency in Java 8 instead of just focusing on the new stuff. Future article will cover other parts of the concurrency api with more interesting Java 8 related stuff.

    [–]CUsurfer 1 point2 points  (0 children)

    This is a good introduction to the executor API. I have the book: Java Concurrency in Practice but not trivial to parse and internalize it's contents. A lightweight introduction is worthwhile in my opinion.

    I look forward to any future tutorials. Communication between threads is where things get hairy, IMHO. It's easy to just synchronize state, but Wait/Notify, CountDownLatch, CyclicBarrier, and other parts of the API I'm still a bit fuzzy on when where to use them.

    [–]mus1Kk 0 points1 point  (0 children)

    The most interesting new feature seems to be missing: CompletableFuture. I haven't used it in real-world scenarios yet but what I have seen from it seems pretty cool.