With a busy rest of the summer ahead of us, it was good to get another mountain done. Hopefully we'll find some time in the superior hiking months of September and October to knock off a few more!
July 27, 2010
Mount Moriah
With a busy rest of the summer ahead of us, it was good to get another mountain done. Hopefully we'll find some time in the superior hiking months of September and October to knock off a few more!
Labels:
4000 Footers
,
Hiking
,
Personal
July 20, 2010
Future Interrupted
I always thought of Java's Future interface as a fairly elegant and effective way of dealing with asynchronous tasks. It's lightweight, gives you a mechanism to check if a task is finished, allows you to block until the task completes and retrieve its result, and also provides a hook to attempt to cancel the task via interruption. When used in conjunction with the various thread pool services in
Yesterday, though, I discovered a subtle distinction about the semantic behavior of the
Essentially, call
The worst part about this is that it is not immediately clear from the javadoc for the Future interface that this is the actual behavior. The description of the
I struggled for a bit to come up with a reasonable alternative mechanism for accomplishing this behavior short of re-implementing my own thread pool and managing the threads myself. Fortunately, after speaking with a colleague, I was pointed to the beforeExecute and afterExecute hooks on the
Anyhow, that's my tidbit for the day. Be careful when playing with the
java.util.concurrent package, it becomes a simple, yet powerful tool.Yesterday, though, I discovered a subtle distinction about the semantic behavior of the
Future interface that slightly diminishes its power. I found myself in a situation where I wanted to cancel a Future, but then still wait until its associated task has completed. Initially I thought this might be accomplished with something like this: // send an interrupt to the task's thread
future.cancel(true);
// block until the task is complete
boolean finished = false;
boolean interrupted = false;
while (!finished) {
try {
future.get();
finished = true;
} catch (CancellationException ce) {
// task has been cancelled, handle appropriately
finished = true;
} catch (ExecutionException ee) {
// task completed with error, handle appropriately
finished = true;
} catch (InterruptedException ie) {
// current thread has been interrupted, record and continue
interrupted = true;
}
}
// re-interrupt this thread if we've been interrupted
if (interrupted) {
Thread.currentThread().interrupt();
}
Essentially, call
cancel(true) on the Future in order to send an interrupt to the associated task's thread. Then call get() on the Future in a loop to ensure that the task has properly handled the interruption and completed execution before proceeding. However, the above code does not work as expected. The problem is that once you call cancel() on a Future, the task's thread will be sent an interrupt if it is running, but then the state associated with the task is completely cast aside. Subsequent calls to get() on the same Future will always immediately throw a CancellationException and there is no available mechanism to block until the task's thread has completed handling the interruption and finished its execution.The worst part about this is that it is not immediately clear from the javadoc for the Future interface that this is the actual behavior. The description of the
cancel() method is very clear that if the task has not started, it will prevent it from starting, but if it has already started, it can make an attempt to "cancel" it via interruption of the task's thread. Of course, since in Java interrupting a thread is only a suggestion for it to actually stop what it's doing, there's no guarantee about when or if the task will actually stop unless you handle the interruption properly. Therefore, I hoped that calling get() would wait for the computation to complete, and then throw a CancellationException if the thread was interrupted. After testing it and also digging through the Java source code for the Future implementation, I discovered that that is definitely not the case.I struggled for a bit to come up with a reasonable alternative mechanism for accomplishing this behavior short of re-implementing my own thread pool and managing the threads myself. Fortunately, after speaking with a colleague, I was pointed to the beforeExecute and afterExecute hooks on the
ThreadPoolExecutor. It takes a little more work then I had hoped, but using those hooks allows you to augment the functionality of ThreadPoolExecutor to achieve this type of behavior. I'll leave the details of it up to you.Anyhow, that's my tidbit for the day. Be careful when playing with the
Future!
Labels:
Tech
May 7, 2010
4000 Footers Status
This post is intended to serve as a real-time status report of our quest to join the White Mountain 4000 Footers Club. Personally I've hiked probably more than a dozen of these mountains in the past, but this list will only contain dates and reports of instances where Katy and I hiked the mountain together. I will update it with links to trip reports as we continue to make progress.
Labels:
4000 Footers
,
Hiking
,
Personal
April 24, 2010
Mount Tecumseh
Fun and easy five mile hike. Perfect weather. Great company. Just what I needed.
Labels:
4000 Footers
,
Hiking
,
Personal
March 11, 2010
What's Next?
So what's next for me? I'm happy to say the initial trauma of being laid off is gone, but not without sentiment. Sun Microsystems is the first company that I worked for as a fresh, green college graduate, and I like to think that my experiences there took a very unique path. I started off as a QA Engineer, automating tests for hardware products used directly by paying Sun customers. From there, I transitioned into a tools developer role, developing and supporting an automation framework used by the rest of the QA team(s). My "customers" while in that role were all internal Sun employees. Finally, I moved into Sun Labs on the Project Darkstar team, where technically, as a research project, we didn't have any customers. In practice, though, we provided direct support to users through the open source community. While going through it all, it seemed like a very natural progression for my career; but looking back, I realize that it's a real valuable trifecta of experiences that not many are fortunate enough to claim.
It was very hard for me initially when Project Darkstar was canceled; it was more than just the obvious emotions that come with losing your job though. There's one other experience from my past that I can compare it to. The circumstances were different, but the feelings and the emotions were eerily similar. For four years while at RPI, I was a member of the track and field team. It was more than just an extra-curricular for me, though, it was my primary focus. I was a highly competitive, contributing member of the team, and was one of the team captains in my final season. Each of the four years that I was there, we won the NYSCTC outdoor state track and field championships; I felt like I was part of something great. The 2005 ECAC championships was my final track meet in my collegiate career. Even though I knew going into it that the meet would be my last, I was not prepared for the emotions that I would feel afterwards. For four years I was part of something great, and just like that it was over. I still remember lying in bed that night, surprised at my own tears.
With Project Darkstar, I also felt like I was part of something great. Not only was it a great project, not only were we driving towards a goal that had never been achieved before, but we were also a great team. There were such a unique set of personalities on that team that all meshed together to form a sum greater than its parts. Not only that, but we were nestled inside of Sun Labs, which is probably one of the smartest collection of people you'll ever find. The way that it was all torn away from us, so harshly and abruptly, and when we were so close to our goal, is what made it so difficult. Once again, I had established my place in something that was great, and just like that it was over.
It's time to move on, now, though. If I've learned anything from my past it's that there's always something great waiting in my future. I've accepted a new position as a software engineer at Nokia and am actually very excited to begin work on Monday. I'll be working on some scalable caching and indexing infrastructure for their service platforms, and am looking forward to a new and interesting challenge. I also plan to continue working on Project Darkstar's successor, RedDwarf Server in my own personal free time. I obviously expect my available time to devote to that effort to be considerably more limited than it has been, however.
Things are looking up, and I'm looking forward to my next great thing.
It was very hard for me initially when Project Darkstar was canceled; it was more than just the obvious emotions that come with losing your job though. There's one other experience from my past that I can compare it to. The circumstances were different, but the feelings and the emotions were eerily similar. For four years while at RPI, I was a member of the track and field team. It was more than just an extra-curricular for me, though, it was my primary focus. I was a highly competitive, contributing member of the team, and was one of the team captains in my final season. Each of the four years that I was there, we won the NYSCTC outdoor state track and field championships; I felt like I was part of something great. The 2005 ECAC championships was my final track meet in my collegiate career. Even though I knew going into it that the meet would be my last, I was not prepared for the emotions that I would feel afterwards. For four years I was part of something great, and just like that it was over. I still remember lying in bed that night, surprised at my own tears.
With Project Darkstar, I also felt like I was part of something great. Not only was it a great project, not only were we driving towards a goal that had never been achieved before, but we were also a great team. There were such a unique set of personalities on that team that all meshed together to form a sum greater than its parts. Not only that, but we were nestled inside of Sun Labs, which is probably one of the smartest collection of people you'll ever find. The way that it was all torn away from us, so harshly and abruptly, and when we were so close to our goal, is what made it so difficult. Once again, I had established my place in something that was great, and just like that it was over.
It's time to move on, now, though. If I've learned anything from my past it's that there's always something great waiting in my future. I've accepted a new position as a software engineer at Nokia and am actually very excited to begin work on Monday. I'll be working on some scalable caching and indexing infrastructure for their service platforms, and am looking forward to a new and interesting challenge. I also plan to continue working on Project Darkstar's successor, RedDwarf Server in my own personal free time. I obviously expect my available time to devote to that effort to be considerably more limited than it has been, however.
Things are looking up, and I'm looking forward to my next great thing.
Labels:
Personal
February 18, 2010
Oh LaTeX how you taunt me
Here's a good one. Since I'm currently unemployed and looking for a job, naturally I've been sending resumes out. I've used LaTeX to generate my resume for years now, and it has always worked out quite well. However, today I had a need to print out my resume, and when I did, I noticed that the font seemed slightly too small, and that the right margin seemed a bit too big. It looked fine on the screen in my PDF viewer, but not on the physical printout. Hmm. As it turns out, I accidentally generated the PDF file with A4 size paper and all of the electronic versions I have sent out thus far have been this A4 version. Grrrr!
I must have come across and handled this issue before, but at least on my Ubuntu installation, PDF documents generated by sequential latex, dvips, and ps2pdf commands default to A4 size paper. In order to get the correct US style letter paper, I have to explicitly use the "-t letter" option in dvips. After rooting around a bit, the command "texconfig paper letter" has changed my default system paper size for dvips, dvipdf, xdvi, and hopefully I'll never make this mistake again!
P.S. Metric system? One day we will give in to your logical structure and simple unit conversion. Clearly, though, that day is not today.
I must have come across and handled this issue before, but at least on my Ubuntu installation, PDF documents generated by sequential latex, dvips, and ps2pdf commands default to A4 size paper. In order to get the correct US style letter paper, I have to explicitly use the "-t letter" option in dvips. After rooting around a bit, the command "texconfig paper letter" has changed my default system paper size for dvips, dvipdf, xdvi, and hopefully I'll never make this mistake again!
P.S. Metric system? One day we will give in to your logical structure and simple unit conversion. Clearly, though, that day is not today.
Labels:
Personal
February 15, 2010
Still Playing Ultimate
Repeat visitors to this blog may be wondering: what happened to my frequent ultimate frisbee status updates? Well, the status updates may have petered out, but that doesn't mean I'm not still playing. I'm still very much attending the regular Monday, Wednesday, and Friday lunchtime pickup games in Burlington. It's business as usual in that department. In fact, I'm kind of regretting not signing up for the BUDA winter indoor hat league that's currently underway in Milford. It's probably for the best that I missed the boat on that though as while I really loved playing in that league the previous times that I've done it, that indoor turf can be pretty brutal on the knees and feet.
Anyhow, one other bit of ultimate news is that Walter Fredrick Morrison has died at the age of 90. Morrison is regarded as the "father of the frisbee". And to reinforce the notion that the sport is dominated by geeks, the story was picked up by Slashdot and hit the front page a couple days ago.
I always thought that Marty McFly invented the frisbee in 1885 though...
Anyhow, one other bit of ultimate news is that Walter Fredrick Morrison has died at the age of 90. Morrison is regarded as the "father of the frisbee". And to reinforce the notion that the sport is dominated by geeks, the story was picked up by Slashdot and hit the front page a couple days ago.
I always thought that Marty McFly invented the frisbee in 1885 though...
Labels:
Ultimate
Subscribe to:
Posts
(
Atom
)