Thursday, April 30, 2009

Synchronized Statement and Nested Classes in Java

I just encountered something in Java that I thought was worth mentioning. It's not exactly a gotcha, but it's good to be aware of.

If you have a nested instance class, synchronizing on this in the inner class is not the same as synchronizing on this in the outer class. This may seem obvious, but it is worth noting because the inner class can refer to methods of either the inner or the outer class in a seemingly ambiguous manner (without explicit qualification). Here's an example program, and its output:

public class WhatIsSyncQualThis {
 
class IJustDriftedAway {
void superFoo() {
synchronized(IJustDriftedAway.this) {
if( Thread.holdsLock(WhatIsSyncQualThis.this) )
System.out.println("1 - held");
}
synchronized(this) {
if( Thread.holdsLock(WhatIsSyncQualThis.this) )
System.out.println("2 - held");
}
synchronized(WhatIsSyncQualThis.this) {
if( Thread.holdsLock(this) )
System.out.println("3 - held");
}
synchronized(this) {
if( Thread.holdsLock(this) )
System.out.println("4 - held");
}
}
}
void fooIt() {
(new IJustDriftedAway()).superFoo();
}
public static void main(String[] args) {
System.out.println("Running");
(new WhatIsSyncQualThis()).fooIt();
System.out.println("Done");
}
}

Output:
Running
4 - held
Done

If you know how nested instance classes are implemented, this is not at all surprising. A separate class is created that takes as a constructor argument a reference to an instance of the outer class. So there are two separate instances upon which we are synchronizing.


Tuesday, April 28, 2009

Sick Party


IMG_8095
Originally uploaded by Genug.
Some pictures were posted from Cortney's party, where we played on Saturday!

Monday, April 27, 2009

I'm Eating Hummus

Make sure to check out the Hummus rap.

Sunday, April 26, 2009

Hectic, Fun Weekend

Oh man, this weekend was really busy, but really fun. Those of you around Pittsburgh know that the weather was unbearably nice, and everyone was outside with their dogs and gardens and iced coffees and whathaveyous.

Friday night I joined some Pitt students who were celebrating the end of their semester. Thanks to the weather, a normal party turned into a porch party, which was quite a bit of fun. Only problem? I didn't get home until like two, even though...

The next morning I woke up at 9 or so for the 11am Urban Hike. It was the first one of the season! We were in the Mt. Oliver/Allentown area. That's sort of in between the south side slopes and Mt. Washington. It was really nice mostly due to the weather, but there was a good crowd, a couple people brought their dogs, and we even discovered a new park, Grandview Park, with great elevated views of downtown.

Than night, a Sick Ridiculous concert! We played at a party for our friend Cortney's birthday. The sound was really good for a party, and the fact that we had an extremely audience resulted in a large amount of fun being had by me and Tom. Thanks to those of you who were there. We wrote a new song about universal heath care and time traveling robots called, "Come with me if you want to live."

Today, we had another Sick Ridiculous show, this time at Lawrenceville's Art All Night. While the crowd wasn't quite what I heard it was the night before, it was surprisingly good for 10:30am. I did think our playing suffered a bit. I think we need more warmup or something, but it took about 15 minutes before we were clicking and sounding decent. Thanks DOUBLE if you made it out this am.

Then, lunch of Dim Sum, afternoon backyard sitting and dinner at the Grand Concourse in Station Square. I will go pass out now!

Friday, April 24, 2009

Kevin's Defense & Bite of Brecht

Man, it seems like everyone is defending or proposing these days!

Yesterday I went to Kevin Bierhoff's thesis defense. Since my work is based on his and also he is my friend, I thought it'd be a good idea to check it out. The defense was great. There was a huge turnout. He passed. The talk went well, if a little light on the technical details, but it was great for a general CS audience. Later that night we went to Bites & Brews to celebrate. Congratulations Kevin!

I also went to see Bite of Brecht, a play on campus that focused on the poetry of Bertolt Brecht. Among other things, it included the song Mack the Knife, which he wrote for the Threepenny Opera. I was expecting some avant-garde garbage based on the lukewarm review in the City Paper, but I actually found it to be quite entertaining. The music was good. The acting was good. There were some funny parts. It did seem to drag a bit at the end, but that was my only complaint. Check it out.

Saturday, April 18, 2009

Scala + SDL


Gradients RuleAfter spending a lot of time doing pointless things, I finally got SDL to work with Scala. Actually, there was nothing tricky about the fact that I was using Scala, that was just part of my original goal. You could equally well say I couldn't get SDL to work with Java. It was pretty obvious that I needed to download SDL.dll and the bindings for Java (both a jar file and some more DLLs), but even then things still weren't working. I was getting the dreaded java.land.UnsatisfiedLinkError. 

Turned out I needed to do three things...
- Add -Djava.library.path= as a VM argument, giving it there folders where both the SDL DLLs and the sdljava DLLs were located.
- Add System.loadLibrary("XXX") for each of the required DLLs into the code itself. This is difficult because it's kind of hard to figure out which DLLs are required! I used this tool to figure it out. 
- Lastly, the biggest problem was that I needed a DLL that I didn't have, SDL_image.dll. The tutorial I was using needed it, but I guess it didn't say or I didn't see where I needed to download it separately. You can get it here.

Thursday, April 16, 2009

Waffleweb

Check out the Waffle Shop web site right now to see the cool dudes who are on the front. Then go to the "About" section to see yourself (at least if you went to the show). 

Tuesday, April 14, 2009

Waffle Shop Pictures


The Dance.
Originally uploaded by drxiv.
Check out some pictures from the Waffle Shop Show! Someone who works there took some (that's drxiv) and Tom took some too.

Update:
Hey! Turns out drxiv doesn't actually work at the Waffle Shop, but is rather a CMU grad student just like me! Still, thanks!

Monday, April 13, 2009

Portmeanteau-yeah!

After several similar conversations with Tom, I have decided to start keeping track of portmanteaus that I personally discovered. (Portmanteau fans believe that all portmanteaus already exist in nature.) The list is pretty small now, while I try to remember some of my back catalogue...

Portmanteau

Sunday, April 12, 2009

Waffle Shop! Waffle Shop!

Last night's show at the Waffle Shop went really well! Thanks to those of you who made it out, we hope you had a great time. And as always, no guilt to those of you who didn't make it. Our bylaws explicitly prohibit the guilt-tripping of our own friends!

Technically, the show went okay. We thought it sounded pretty good, and definitely better now that Tom has a new guitar with a built-in pickup. However nothing beats professionally managed sound, like that that we received at the Lava Lounge. When we're doing the sound ourselves, it kind of hard to tell about the overall volume, mix, etc.

But fun-wise, the show was great. I think the Waffle Shop is a great place to play, we got interviewed, we got to debut our own custom waffle, Twix Ridiculous and the Sick Bisquik-ulous, a waffle with baked-in Twix candy bars, and there was a great turn-out. I think this may have been the most people they ever had at the Waffle Shop, based on the way that the people working there were taking pictures. Actually, that would make plenty of sense since normally people won't come in if all the tables are occupied (they were) but they will come in if there is a band playing, even if there is no more available room (they did)!

Pretty soon we should have some pictures up, and a little bit later we may even have a link to our interview. You see the Waffle Shop is some kind of reality TV show on the Internet, and as part of our performance there was a bandatory interview. WAFFLE SHOP!

Friday, April 10, 2009

Hockey is Lif

Last night I went to a Penguins hockey game, only the second that I've been to since living in Pittsburgh. It was great! Our tickets were partially subsidized, but since the face value was $100, they still were a little bit of money. No bother. They were great seats, the game was fun, Pittsburgh won 6 to 1 and we even managed to get a bus back home.

Now as you may know, Penguins hockey games take place in Mellon Arena which is soon to be replaced by a new arena of unspecified corporate sponsorship. Mellon Arena (aka Civic Arena, aka The Igloo) is described as an outmoded facility, which I have to say is probably true. Inside it has kind of a dingy feel, and some of the sigh lines are absolutely atrocious, ones you'd never see in a modern arena. If anything I'd have to say it felt a little like the L.A. Sports Arena, which I think is of a similar vintage, although the Sports Arena didn't have any sight lines as bad as some of the ones in Mellon. (One seat had a pole right in front of it, Fenway Park style. And for the only other Penguins game I've been to, we were "sitting" in standing-room "seats" on the periphery with an overhang in front of us that made it impossible to see the other side of the rink.)

One nice thing was that Mellon is pretty small. Even the highest seats still have a great view of the action, which is something you can say about other Pittsburgh sporting facilities (PNC Park, Mustard Palace) but not more modern facilities in L.A. (For example, the Staples Center is an absolute beast of an arena. The highest seat there are really, really high.)

Go Penguins.

Thursday, April 9, 2009

You Want a Waffle With That?


Waffle Shop Poster Let's say this weekend you're walking around East Liberty, minding your own business when all of a sudden you realize, "Man, I am so hungry right now. I sure could use some sugar and startch!" And let's say that you also happen to like music of a, let's say, Business Casual variety. Well it would be to your advantage to walk into the Waffle Shop at 11:15 for a Sick Ridiculous & the Sick Ridiculous show, wherein you will also be served waffles by the friendly patrons.

It's Saturday night, we are the only band, and it's free, save for the money you spend on a waffle. But considering the one time I went there I spent like two bucks on a waffle and another dollar on my hot chocolate, I think you will leave satisfied. 

Special things: We may have a custom waffle. We will have a new song.

Monday, April 6, 2009

SIGBOVIK 2009 Recap, Featuring Arkan∞id

As SIGBOVIK 2009 comes to its glorious conclusion, it's time for me to reflect somewhat.

This year's events was quite successful, for a number of reasons. First, we were in Scaife Hall 125, this amazing conference room which is perfect for the event. I hope we continue to have it there. There were a number of great presentations. The proceedings (which can be purchased or viewed for free here) look amazing. But what's more, there was a great turn-out, and the days events proceeded very smoothly, with the one exception of my maybe having too much coffee. 

There were also a bunch of "real" projects that people spent their time on. For example, check out:And of course, there was my own work! I made a game called, Arkan∞id, the infinite brick-breaking game. (In the spirit of Breakout and Arkanoid.) You see, it's like a normal brick-breaking game, but it goes on forever! Some semi-clever engineering makes it so. Plus, it's a Blackberry game, so you can leave it running all the time! So, here's what you should do:Oh, and one more thing: This research work is award winning! My paper won the 2009 award for "Most Pixels," which really I think I deserved. The award itself was a flash animation, which you can see here, and which itself won the people's choice award for best presentation!

Friday, April 3, 2009

PlayStation

Why is it that whenever it's raining really hard in Pittsburgh the 8:45 and 9:00 54Cs don't show up? Let's get on that.

Yesterday I bought a Playstation2 second-hand from a friend. I've got the first three Guitar Hero games and I'm planning on buying a few more, specifically Katamari and Amplitude. Does anyone else have any PS2 recommendations? I don't have much time to play video games, so I would only be looking for earth-shatteringly awesome video games. Actually, this is one benefit of buying a system after everyone else has played it. It's already pretty well known what the best games for the platform are.