{"id":3372,"date":"2015-01-20T02:55:05","date_gmt":"2015-01-20T02:55:05","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=3372"},"modified":"2015-12-21T00:09:00","modified_gmt":"2015-12-21T00:09:00","slug":"2-java-debugging-tricks","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/2-java-debugging-tricks\/","title":{"rendered":"2 Java debugging tricks"},"content":{"rendered":"<p><strong>1. Embed state in your thread names.<\/strong><\/p>\n<p>Some times when you see a crash log with a thread dump, you see the stack of all the threads at the moment of the snapshot, but there&#8217;s no way to see what the state of the variables and objects at play in the thread were like.<\/p>\n<p>You can use <code>Thread.currentThread.setName(...)<\/code> and embed variable states on the thread name for a more useful thread dump output.<\/p>\n<p><strong>2. Set a <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/Thread.UncaughtExceptionHandler.html\" target=\"_blank\">Default uncaught exception handler<\/a> and log the error to the thread.<\/strong><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Embed state in your thread names. Some times when you see a crash log with a thread dump, you see the stack of all the threads at the moment of the snapshot, but there&#8217;s no way to see what the state of the variables and objects at play in the thread were like. You [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15],"tags":[1425,583],"class_list":["post-3372","post","type-post","status-publish","format-standard","hentry","category-code","tag-debugging","tag-java"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-So","jetpack-related-posts":[{"id":156,"url":"https:\/\/www.gubatron.com\/blog\/portscanner-only-60-lines-of-code\/","url_meta":{"origin":3372,"position":0},"title":"PortScanner &#8211; Only 60 lines of code","author":"gubatron","date":"May 19, 2005","format":false,"excerpt":"Hi, here's a simple port scanner I wrote today in Java. I needed to see something on my server, perhaps you can find it useful. I would say its pretty fast, you can tweak the number of threads and timeouts to adjust to your server\/connection. I did't do much testing\u2026","rel":"","context":"In &quot;Gubatron&quot;","block_context":{"text":"Gubatron","link":"https:\/\/www.gubatron.com\/blog\/category\/gubatron\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":611,"url":"https:\/\/www.gubatron.com\/blog\/pyqt4-using-qmutex-vs-qmutexlocker\/","url_meta":{"origin":3372,"position":1},"title":"PyQt4: Using QMutex vs QMutexLocker.","author":"gubatron","date":"November 25, 2007","format":false,"excerpt":"Here's some code for my future reference on how to use QMutex or QMutexLocker. Lessons Learned: * Use QMutex to protect data, not code. Try not to lock hughe amounts of code within a function with mutex.lock(), mutex.unlock(), if for any reason you forget to release the lock you'll be\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3241,"url":"https:\/\/www.gubatron.com\/blog\/setting-up-eclipse-as-your-ide-for-bitcoin-c-development-on-macosx\/","url_meta":{"origin":3372,"position":2},"title":"Setting up Eclipse as your IDE for Bitcoin C++ development on MacOSX.","author":"gubatron","date":"February 9, 2014","format":false,"excerpt":"If you are a Java developer used to the productivity levels achieved by working with eclipse's code navigation, code completion and refactoring tools, it's worth your time staying in eclipse for any sort of C++ development. This post refers specifically to getting your eclipse environment to work with a particular\u2026","rel":"","context":"In &quot;BitCoin&quot;","block_context":{"text":"BitCoin","link":"https:\/\/www.gubatron.com\/blog\/category\/bitcoin-2\/"},"img":{"alt_text":"Screen Shot 2014-02-09 at 1.09.39 PM","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.09.39-PM.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.09.39-PM.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/02\/Screen-Shot-2014-02-09-at-1.09.39-PM.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2931,"url":"https:\/\/www.gubatron.com\/blog\/how-to-enable-adb-logcat-debugging-output-on-android-4\/","url_meta":{"origin":3372,"position":3},"title":"How to enable adb logcat  on Android 4 (debugging output)","author":"gubatron","date":"March 4, 2013","format":false,"excerpt":"So you got a new Nexus or another Android running Android +4.2 and there's no \"Applications\" menu entry in the settings menu. No worries. Go to the \"About phone\" entry at the bottom of settings, then scroll all the way down to the \"Build number\" menu entry. Tap on it\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3272,"url":"https:\/\/www.gubatron.com\/blog\/new-frostwire-5-7-2-with-utp-support\/","url_meta":{"origin":3372,"position":4},"title":"New FrostWire 5.7.2 with uTP support","author":"gubatron","date":"April 12, 2014","format":false,"excerpt":"Download FrostWire 5.7.2 for Windows\u00a0(Bitcoin, Litecoin, Dogecoin enabled .torrent) Download FrostWire 5.7.2 for MacOSX\u00a0(.torrent) Download FrostWire 5.7.2 for Debian\/Ubuntu\u00a0(.torrent) This release is all about performance and stability. Some users have complained about what happens to their internet connection when using FrostWire heavily, so we\u2019ve finally added uTP support to solve\u2026","rel":"","context":"In &quot;FrostWire&quot;","block_context":{"text":"FrostWire","link":"https:\/\/www.gubatron.com\/blog\/category\/frostwire\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3376,"url":"https:\/\/www.gubatron.com\/blog\/what-to-do-when-lighttpd-wont-start-and-wont-give-out-any-error-output\/","url_meta":{"origin":3372,"position":5},"title":"What to do when lighttpd won&#8217;t start and won&#8217;t give out any error output?","author":"gubatron","date":"February 4, 2015","format":false,"excerpt":"So you upgraded your server, or just all of a sudden you try to start lighttpd, it says the server started ok, but you check and there's no lighttpd process. You then go after your error log files, and nothing... what the fuck is happening? try this to attempt to\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=3372"}],"version-history":[{"count":3,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3372\/revisions"}],"predecessor-version":[{"id":3411,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/3372\/revisions\/3411"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=3372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=3372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=3372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}