Superdeformed
You do NOT want to see what I've been doing with threads lately...
OK, so last Monday, I came back Violently Happy from the weekend, having solved one of my QuickTime for Java threading problems that was causing crashing problems on Intel Macs. Only problem was that it locked up hard on Windows XP.
So I looked into it. And it's crazy bizarre. Here's the deal: when you use QTJ's capture manager, the SequenceGrabber, you periodically need to manually give it some CPU time. Yes, it's a holdover from the bad old days of MacOS 1 through 9 and "co-operative multi-tasking". But it's so so simple in Java: it takes five lines to kick off a thread that repeatedly calls SequenceGrabber.idle() and then Thread.sleep()'s for a while. You just need to be sure you don't do that from AWT-Event-Dispatch (i.e., don't use a javax.swing.Timer) because on the Mac, the AWT-Event-Dispatch and the Cocoa AppKit's RunLoop thread are really keen on either deadlocking or crashing each other (AppKit usually wins that fight).
So I've got my own Thread giving time to the SequenceGrabber. And I'm getting callbacks every time there's new capture data, so I can decompress the image and blit it to an AWT/Swing canvas. Of course, these callbacks are on my thread that's giving time to the SequenceGrabber.
Well, they are on the Mac, anyways.
Somehow, on Windows, my idler thread is completely ignored, and SequenceGrabber.idle() is repeatedly called by the AWT-Windows thread... which happily deadlocks itself on a call to decompress the captured image.
So I found a workaround... and it's pretty nasty. Basically, the problem is what thread's calling the image decompressor. So, the solution is to call that from another thread. So, in my callback, I look at the current thread and check to see if it's the idler thread. If it's not, then I kick off a new thread that goes right back into the same block of code, while back on AWT-Windows, I return immediately and unblock the GUI. There are a few checks for safety (not running two of these ad hoc threads at once, making sure the repaints are properly put back on event-dispatch with a SwingUtilities.invokeLater(), etc.), but that's the gist of it. Woo hoo, a capture preview that works on all three of my target platforms.
So that's how I spent part of my weekend... a crazy workaround, but I'm fortunate that Java threads are fairly easy to create and use. There was an Artima thread the other day about how programmers are going to need to think more aggressively multithreaded to behave well in a multi-core CPU world, and while this might not be a big concern for some server-side developers (if the app server is making the decisions about how to thread requests), it's critical for desktop developers to really get threads, something that's easy to overlook when Swing generally wants you to do everything GUI-related on its event-dispatch thread.
Speaking of QuickTime for Java, this week's Spotlight is on Elliotte Rusty Harold's Amateur, a free, open-source clone of Apple's QuickTime Player Pro written in Java, without the feature crippling and registration fees. Started as a reaction to another upgrade fee to QuickTime Pro, the application uses QuickTime for Java and its most recent version, 1.0d6, implements most of the playback and editing features of Apple's player app. The current version is tested only on Mac, though a Windows version is thought to need just a few hours' work.
In Java Today,
the Web Services Policy Working Group has released First Public Working Drafts of the Web Services Policy 1.5. The Policy Framework defines a model for expressing the nature of Web services in order to convey conditions for their interaction. An attachment defines how to associate policies, for example within WSDL or UDDI, with subjects to which they apply.
Srini Penchikala offers a thorough overview of the database changes in Mustang in JDBC 4.0 Enhancements in Java SE 6. He writes: "The main objectives of the new JDBC features are to provide a simpler design and better developer experience. This article provides an overview of the JDBC 4.0 enhancements and what benefits they offer to enterprise Java developers." Among the topics he covers: auto-loading of JDBC driver classes, connection management enhancements, support for the RowId SQL type, DataSet implementation of SQL using Annotations, and more.
The Grid Institute announced that Sun Microsystems is collaborating with the MediaGrid.org open standards group to advance international standards for storing, delivering and processing digital media in Grid computing environments. A key component of the collaboration is the seamless connection of Sun Microsystems' on-demand Sun Grid compute utility to the public Media Grid network, enabling Media Grid service requests and jobs to be handled by Sun Grid. In addition to increasing the quality of service and overall performance of the Media Grid network, "gatewaying" to Sun Grid will also have a direct and positive influence on related MediaGrid.org standards.
Now that Ethan Nicholas is at Sun, he's the one in the hot seat to start implementing some of the features he's been calling for. In today's Weblogs, he checks in with the blog entry
Welcome to the Deployment team: My first week at Sun
It turns out that I joined Sun at a fortuitous moment -- just in time to get involved in the Dolphin (Java 7) planning process. Read on for a sneak peek at what's in store for Deployment.
Tim Boudreau introduces some
NetBeans Modules for HTML Authoring: "I write tutorials and articles quite a bit. NetBeans is an excellent editor for HTML, but there were a few things missing. So I wrote some modules to plug the gaps."
Brian Repko says he
Ain't gettin' no rest with REST:
"After alot of reading, some thoughts on REST and the whole 'are 4 verbs enough' question..."
mikeazzi asks A Quick JTable Drag n Drop QuestionIn today's Forums:
"I am trying to write a small Drag n Drop example that involves draging a text string from a text field to a JTable. So I installed a very simple TransferHandler on JTable which pretty much implemented the canImport() method to accept drops. The drag gestures seem to work fine between the text field and the JTable. But the one thing that's bothering me is that when the drag cursor is above a row in the JTable, ONLY ONE cell in that row is highlighted, not the entire row. I would have expected the whole to be highlighted, and I couldn't figure out why, or how to tell it to do that. I have tried playing with the setDropMode() method, with no luck."
It's not clear whether demi123 is having a problem with Eclipse or with GlassFish in the discussion of
How does one install/use the Eclipse plugin?
I have Eclipse 3.2 and the milestone 0.3 Eclipse plugin for Glassfish. I installed it by unzipping the zip file to the eclipse directory, and it seems to have been the right place, because the plugin shows up in the Eclipse plugin list (two entries from netbeans.org). Still, I can't see the Glassfish server entries in the New server dialog. In fact, the contents didn't change at all. I have successfully used a JBoss server before with their respective plugin, in Eclipse 3.2 of course. What am I doing wrong?
In today's java.net
News Headlines :
- The TrueLicense
Library Collection 1.28 - JTrac 2.0-RC2
- Sleep 2.1-b2
- Jakarta
Commons Attributes 2.2 - TrueZIP
5.1.8 & 6.2 - Castor 1.0.2
Registered users can submit news items for the
href="http://today.java.net/today/news/">java.net News Page using our
news submission
form. All submissions go through an editorial review before being
posted to the site. You can also subscribe to the
href="http://today.java.net/pub/q/news_rss?x-ver=1.0">java.net News RSS
feed.
Current and upcoming Java
Events :
- August 18-20 - New York Software Symposium 2006
- September 6-8 - EclipseWorld
- September 12-15 - Enterprise Java Architecture Workshop Chicago
- September 12-14 - JavaZone 2006
- September 15-17 - Pacific Northwest Software Symposium 2006
- September 22-24 - Western Canada Java Software Symposium 2006
- September 29-October 1 - New England Software Symposium 2006: Fall Edition
Registered users can submit event listings for the
href="http://www.java.net/events">java.net Events Page using our
href="http://today.java.net/cs/user/create/e">events submission form.
All submissions go through an editorial review before being posted to the
site.
Archives and Subscriptions: This blog is delivered weekdays as
the Java
Today RSS feed. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the
href="http://today.java.net/today/archive/">java.net Archive.
You do NOT want to see what I've been doing with threads lately...
- Login or register to post comments
- Printer-friendly version
- editor's blog
- 636 reads





