Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18917

Re: Interrupted exception chaining

From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: Interrupted exception chaining
Date 2012-09-25 12:00 -0700
Organization A noiseless patient Spider
Message-ID <k3sv09$lgp$1@dont-email.me> (permalink)
References <d203b18b-61ce-439e-9b1f-9cf056c1d161@googlegroups.com> <k3sirj$5of$1@dont-email.me> <5ec3b39d-32ee-4956-a8f2-1ae18e9d0924@s8g2000vbc.googlegroups.com>

Show all headers | View raw


On 9/25/2012 9:28 AM, Ivan Ryan wrote:

> It was to implement an interface.
> https://github.com/SpoutDev/SpoutAPI/blob/master/src/main/java/org/spout/api/util/concurrent/SpinLock.java


This looks 100% bogus to me.  First, the JVM will insert spin-locks 
where needed in your code automatically.  No need to try to build your 
own.  The first rule of programming is "Don't re-invent the wheel." 
(The 0th rule is "Get a deposit with all contracts.")

Second this is exactly the sort of situation where hiding an 
InterrruptedException will get you into trouble.  Better to just 
re-throw and let the calling code deal with the exception (if desired).

But even better to just delete this class and use 
java.util.concurrent.locks.ReetrantLock or something similar from the 
Java API.

Plus, existing locks are more efficient that you might guess.  I don't 
think an AtomicBoolean is going to beat them.  Look into 
AbstractQueuedSynchronizer or LockSupport if you really must implement 
your own subclass of Lock.

<http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/concurrent/locks/ReentrantLock.java#111>


Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Interrupted exception chaining raphfrk@gmail.com - 2012-09-25 03:25 -0700
  Re: Interrupted exception chaining Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-25 08:56 -0400
  Re: Interrupted exception chaining markspace <-@.> - 2012-09-25 08:33 -0700
    Re: Interrupted exception chaining Ivan Ryan <ivan.ryan@gmail.com> - 2012-09-25 09:28 -0700
      Re: Interrupted exception chaining Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-25 13:12 -0400
      Re: Interrupted exception chaining markspace <-@.> - 2012-09-25 12:00 -0700
  Re: Interrupted exception chaining Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-09-25 09:22 -0700
    Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 22:26 +0200
      Re: Interrupted exception chaining markspace <-@.> - 2012-09-25 13:37 -0700
        Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 22:47 +0200
          Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 22:53 +0200
            Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 22:53 +0200
          Re: Interrupted exception chaining markspace <-@.> - 2012-09-25 14:08 -0700
            Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 23:23 +0200
              Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 23:24 +0200
              Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 23:32 +0200
            Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 23:42 +0200
              Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 23:48 +0200
              Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-25 23:55 +0200
                Re: Interrupted exception chaining markspace <-@.> - 2012-09-25 15:33 -0700
      Re: Interrupted exception chaining Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-25 21:43 -0400
  Re: Interrupted exception chaining Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-09-26 01:43 +0200
    Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-26 10:24 +0200
      Re: Interrupted exception chaining Jan Burse <janburse@fastmail.fm> - 2012-09-26 10:32 +0200
        Re: Interrupted exception chaining Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-09-26 16:26 +0200

csiph-web