Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Sunday, August 14, 2011

some java basics

It's another hot, hot day in Tokyo.
Days like this make me realize how important it is to live in a place that has good air circulation (i.e. wind flow 風当たり). Of course, that's often difficult when buildings are built close together, meaning that convenient places tend to have less of a breeze.

Anyway, I came across some good articles clarifying some Java fundamentals. The basics are not necessarily simple.

Java is Pass-by-Value!
Specifically, Java passes object references by value.
* The above article includes a reference to an article explaining C++ Reference Variables, a good explanation of the general concept of reference variables.

Exploring Java: Threads

* What is a daemon thread? When should I use setDaemon() and why?
Use thread.setDaemon(true) to tell the JVM to make the thread a daemon thread.

According to Webster's, a daemon (variant of demon) is an attendant power or spirit. Daemon threads are typically used to perform services for your application/applet (such as loading the "fiddley bits"). The core difference between user threads and daemon threads is that the JVM will only shut down a program when all user threads have terminated. Daemon threads are terminated by the JVM when there are no longer any user threads running, including the main thread of execution. Use daemons as the minions they are.

[In short: daemon threads do not keep the program from quitting; user threads keep the program from quitting. -Alex]

Synchronized block vs. method:
The only real difference is that a synchronized block can choose which object it synchronizes on. A synchronized method can only use 'this' (or the corresponding Class instance for a synchronized class method).
- http://stackoverflow.com/questions/574240/synchronized-block-vs-synchronized-method/574253#574253
* http://stackoverflow.com/questions/416183/in-java-critical-sections-what-should-i-synchronize-on
* http://stackoverflow.com/questions/417285/equivalent-code-for-instance-method-synchronization-in-java
* http://www.coderanch.com/t/234017/threads/java/Threads

Sunday, July 31, 2011

what I need is some accountability

Inspired by this blog, I thought that one way to keep me working on my personal programming project would to have some visible external record of my progress or lack thereof.

This week, I started fleshing out the design of my HappyTrack mood tracking program.

I went off on 2 tangents:
* unit testing:
* Localization/internationalization
I'd like the app to support multiple languages in a relatively flexible, intelligent manner.

Once my program is reasonably usable, I'd like to play with Scala. As most of my experience lies with Java, Scala seems like a natural area to branch into.

However, next month I also start learning Haskell in earnest! I hope I can make faster progress with HappyTrack soon.

Expect another report in a week at the latest.

Wednesday, July 16, 2008