A tough Java question on threads

After reading my core Java interview questions, my friend and a colleague Mike Polyak said that I should include the following advanced interview question on Java threads synchronization:

In the class below, is method getIt() thread safe and why?

public class X {

private long myVar;

public void setIt(long var){

myVar = var;

}

public long getIt() {

return myVar;

}

}

If you have an idea what “s the right answer is, feel free to write it in the Comments section of this blog. I “ll publish the answer in a week in this very blog, so stay tuned hellip;

Happy Independence Day for those who celebrates it!

The Ukraine is outsourcing its folk music to Harlem

Text blogs or even podcasting are so old-fashioned…Video blogs is the way to go!

If you understand the Ukrainian language, you’ll enjoy this video, which is a bit unusual interpretation of the popular folk song that Ukrainian people sing after 10-15 straight shots of vodka at the parties. This song is about this girl that keeps setting the time and location for the date on the next day, but never shows up. The poor guy goes crazy and sings, “You lied to me again… ”

And here’s just a great blogger-guitarist or guitarist-blogger:

What do you think of these three Japanese guys?

And of course, the classics: Bohemian Rapsody.

The next one is not from youtube, but just a great song: 101 covers of the Stairways to Heaven

I’d appreciate if you could share some other cool video blogs from youtube.

Your mother is ugly…or marketing strategies

If you are following what “s happening in the Java world, you know the most noted trouble makers: AJAX and Ruby.

After the media heated up these two technologies to several hundred degrees, some people started to take them seriously and move to these technologies for various reasons. I “m not planning/ready to discuss pros and cons of these technologies, but it “s clear that some want to cash in on being early adopters, while others try to promote their AJAX or Ruby books and frameworks.. Speaking of marketing… In my opinion, creators of this masterpiece were thinking about creating dynasties of RoR programmers. Location of the Rails logo assumes that your spouse also knows what ROR is, otherwise s/he won’t be impressed. On the same note, both proud parents of a baby wearing this piece must know what this logo means. We are clearly expecting new generations of RoR developers, which is great, because the last thing I want to see is the Rails logo on the birth control devices.

Anyway, let’s stop right here and return to early adopters. These people and software vendors use one of two strategies:

1. Try to find some common grounds to integrate and communicate with these popular technologies.

2. Start bashing Java whenever they have a chance.

There are people who try to use the first strategy and write good articles that explain what the new languages are about. I receive a printed version of SD Times magazine , which had a really nice and consice article introducing Ruby. Unfortunately, the online version does not have the code samples, which makes it pretty much useless. But this article was good…as well as this video. I’ll be more than happy to publish an article on Ruby in Java Developers Journal, as long as it it delivers any message other than “Java sucks “.

The second strategy is similar to starting a conversation with a statement “Your mother is ugly, and that “s why hellip; rdquo;. Maybe this is right. Maybe his mother is ugly, but do you think that starting a conversation like this helps in achieving your goal?

The smart way of convincing the Java and non-Java crowd to work with newcomers is by creating use cases that show benefits of combining the new and the tried-and-true technologies in a way that compliments each other, and smart software vendors follow this path already. This explains why many software vendors are quickly making their applications AJAX-enabled.

Java programmers should get exposed to new languages and technologies including Ruby and AJAX even from a pragmatic point of view: there are jobs out there. Today, dice.com offers 16000 Java jobs nationwide, 900 Ajax-related jobs and 200 jobs that require Ruby skills. If you live in New Jersey and want to see what is this buzz about, attend our Princeton JUG meeting on Ruby on Rails in August. By the way, I’ll gladly accept RoR book donations for free giveaway to our JUG members.

Your mother looks great, but if she had a nose job done hellip;

Beware of the bloggers!

Availability of the broadband/WiFi Internet connectivity and easy to use tools for blogging causes a an interesting side effect that can not be ignored by people speaking at the conferences, seminars, or any smaller-scale professional meetings.

For example, during the last year or so, I have not used paper notepads to take notes while attending presentations at various public events. You say, what the big deal? But me say, me is connected to the internet and me have a blog. Ahaa! This can turn this electronic notebook a dangerous weapon. Speakers at these events are vulnerable. Some of them are intimidated by a large crowd of people, some of them may not be prepared too well for talking on the subject of their presentation. They may say something that either is not exactly right, or it is right but is intended for a smaller than the entire world audience.

While the speaker speaks blinded by the projector(s), the blogger blogs in the darkness of the audience, and his/her comments become available online instantaneously.

I “ve been on the both sides of the fence, and let me tell you, these blogs are not always a pleasant morning read for the speakers. This situation does not need to be changed as it gives the Web surfers around the globe have immediate commented report on the events of their interests. But just to play fair, the speakers have to be warned by a large poster ” Beware, bloggers are in the audience and they type faster than you speak rdquo;. Even if they do not type while you speak, they’ll do this as soon as they find themselves near that device witha little blinking green light. Honey, I’ll have dinner in fifteen minutes, let me just type somthing real quick…

I “m not sure if this is a good analogy, but casinos do not let professional players in without even explaining the reason. Should bloggers be banned from attending some events? I do not think so, but speakers shold think twice before opening your mouth, bloggers are everywhere and they are not on any non-disclosure agreements.

Adobe Flex 2 has been released today

Adobe Flex 2 has been released as planned. The first question is how much.The quick answer is better than expected, and here “s the breakout:

What “s free:

Flex 2 SDK, command line compilers and Flex Data Services Express (must run on a single-processor server), Flash Player 9, which is actually a virtual machine that “weighs rdquo; only 1.1Mb and is about 10 times faster than Flash Player 8.

What “s not free:

Flex Builder, Eclipse-based IDE: $499 (or $749 with charting components)

Charting components (alone): $299

Flex Data Services, departmental licens up to 100 concurrent users: $6000 per CPU

enterprise license: $20,000 per CPU

Well, I was asking for free Flex Builder, it “s not free yet, but $499 is much better than originally promised “under $1000 “. People with advamced Math degrees may argue that $499 is also under $1000 hellip;

While I “ll keep picketing for free Flex Builder, independent vendors are working on free Flex 2 IDE already, so most likely Adobe will lower this price in the near future.

So let “s see, if you want to create a small community site, it “ll cost you $500 ( one license of FlexBuilder). You get the Flex Data Services, which is a Java Web application that you can deploy in any servlet container, i.e. Tomcat, which is free as Staten Island Ferry.

Managing your manager

The next question is how to manage your manager to make your enterprise an early Flex 2 adopter. This is how I “d do it:

1. Download a trial 30-day Flex Builder and charting components

2. Download Flex Data Services Express ndash; it “s free

3. Start regularly asking your manager to give you five hundred bucks for just one little FlexBuilder license. It should take you about 30 days, meanwhile you can use its trial version (see item 1 above).

4. Volunteer to create a small proof of concept project that would mimic one of the non-Flex applications that are currently being developed/deployed in your shop. Most likely your manager will say that it “s not in the project plan, there are deadlines to meet, and this typical corporate blah-blah. Do not argue, just smile and say in a low voice, “No problem, I “ll do this in my own free time. rdquo;

If you spend 50 hours developing in Flex Builder, most likely you “ll be able to do as much as you “d do programming in Java Swing in 150 hours (well 100 hours using NetBeans/Matisse combo), and your screens will look prettier.

5. If you work for a financial company in New York City, I can come to your firm and do a 45-min Lunch-and-Learn session for free (offer is valid while supplies last).

6. After the initial proof of concept is done, ask your manager to start development of your new project using this one FlexBuilder license and a free Express version of Data Services. If your manager is smart, you “ll get a “Yes rdquo;, otherwise find another job.

For more Flex 2 resources, visit Flex Developers Center , FLex.org, read our article on using Flex with Java, and just Google on Adobe Flex 2. If you are a Flex developer, register yourself at http://www.flexcoders.net/.

We’ve submited a new article to Flex Developers center about a couple of new and cool open source components. Meanwhile check out the demos of the automatic Flex code generator DAOFlex and FlexReporter.

Just take your existing Java application and give it a facelift with Flex 2.

Why Jonathan Schwartz made the list of people who do not matter?

CNN published a list of ten people “who do not matter “. Surprisingly enough, the newly appoined CEO of Sun Microsystems has made this list. This is what they write about Jonathan:

“Sun’s newly appointed CEO is full of ideas – some of which he airs on his blog – and he’s making much-needed cuts in the company’s bubble-bloated workforce. But none of that will be enough to change the underlying dynamic: Sun’s server business has become a commodity, and the company is not making enough money from software like Java to supplement its shrinking hardware profit margins. Schwartz’s latest push – more energy-efficient servers – is rapidly being copied by other computer makers. Sun has always dared to be different, but soon it will have to join the rest of the industry and start making some money too. ”

I do not think it’s fair assessment. The guy has just started and at least deserves some time to try to make a difference. CNN states that this list is just an interesting read…Not too me though…

Here’s another bald statement from the article:

“But as respected as they might be for their past achievements, their best days are behind them. ”

I do not think this applies to Jonathan Schwartz… I hope not.

My role model: Sang Shin

Sang Shin is Java Evangelist working for Sun Microsystems. No, he’s a super evangelist, because besides being a Java guru he’s also passionate about this language. If for any weird reason you do not know his Java Passion site, check it out now. Sang creates these excellent free online courses, he teaches live and online, he’s constantly traveling around the globe promoting this great language/technology that we all enjoy for years. Just check out his calendars for 2006, 2005, 2004…

I know Sang personally, and had a privilege of having him as a speaker on one of my Weekend With Experts seminars. Besides being a great speaker, he’s a very open and friendly person . Last month I’ve seen him at JavaOne: Sang was responsible for running hands-on labs at this event.

Sang’s latest creation is the AJAX Training Workshop.

I do not know how much Sun Microsystems pays him, but I’m sure it’s not enough for what Sang is doing for the popularization of Java technologies around the world.

PowerBuilder to Flex – a Natural Transition

Yesterday, I met yet another Java developer, and all of a sudden, he “s mentioned PowerBuilder. That very second, the conversation became a lot more warmer:

“Remember datawindows? rdquo;

“It was and still is the best RAD tool. No any other technology could beat it. rdquo;

“Forget about it! Nested reports, non-visual objects hellip; rdquo;

“Is there any bar close by? Let “s have a drink rdquo;

There is some kind of unofficial brother/sisterhood of people related to PowerBuilder. In the 90th, I spent five years programming in PB. This was the best RAD tool for business developers. I switched to Java in lsquo;98, but did not lose connections with PB developers : my wife is still doing PB for the last 10 years and I see this DataWindow painter once in a while on her laptop. PB now enjoys a steady double-digit version numbers: Sybase found it much easier to conquer double-digits in versioning than in their financial charts.

More and more industry professionals are into development of full-featured rich desktop-like applications delivered over the Web. While some PowerBuilder developers will remain faithful to their old-fashioned but bread-winning software, a large portion of the PB camp should be looking for an easy transition to another software. In my opinion, such software has arrived Adobe (formerly Macromedia) and it “s called Flex 2.

PB developers will find themselves at home in this solid environment offering an impressive library of GUI components for the fat but fast clients, so-familiar event-driven programming, drag-and-drop screen design, good IDE, debugger, integration with Java on the server, charting, etc. You create your applications using XML-based declarative language and object-oriented ActionScript 3. The compiled source code is runs under popular Flash player, which is a virtual machine available on literally every platform.

The learning curve for PB developers is not steep at all. You “ll feel yourself at home there. You can find a plethora of training materials about this technology at adobe “s Web site (watch a couple of presentation videos there), the closest upcoming seminars on Flex will take place in New York City in August, Max 2006 in Las Vegas will have a Flex track AJAX conference in Santa Clara, CA in October will have a Flex track.

Later this year, I “m planning to run a couple of Flex 2 training classes in New York City for Java and PowerBuilder enterprise developers. Let me known in advance, if interested: enrollment will be limited. Typical questions I get after such announcements are:

1. “Will I find a job using this great tool? rdquo;.

And here “s my typical answer, “I am not a con artist to guarantee employment, this is America! But I do believe that 2007 will be a year of Flex rdquo;.

2. “Are there any books to read on Flex? rdquo;.

Adobe has plenty of introductory materials and full documentation online, a book on ActionScript 3.0 is coming up in September and I “m also working with two of my friends on the advanced book on Flex .

I “m sure my former PowerBuilder students got the message. See you soon, guys

Yours truly,

Yakov Fain

Google toolbar for mere mortals

Back in October of 2005, Google and Sun made a deal to include Google’s toolbar as an option in downloads of Java Runtime.

Yesterday, Adobe announced the signing of a multi-year agreement with Google to distribute the Google Toolbar.

If you are not excactly sure what is this all about, I’ll try to interpret these news.

Search engines are born equal on the premise of making money by selling advertisements. They want you to be your only search engine. Some search engines even give you prizes just for using them.

Let’s do a search…For example, you are looking for a new thingy. Just type the word “Thingy ” in Google and you’ll see the paid advertisement stating that eBay has excactly the right thingy for you on sale.

Do the same thing on Yahoo, and NexTag will be happy to find the bargain for your thingy.

Want Java One? They’ll sell it to you in a heartbeat.

You don’t have to be a rocket scientist to figure out that the search engine companies make money each time you click on these ads. Some startup search engines even will even offer points/awards for the loyal users.

So, Google wants you to use Google only for 100% of your searches. How to achieve this? Elementary, Watson! By displaying their little toolbar on each and every popular software product. Say, you like Adobe’s media shockwave player and use it daily. Keep using this nice product, and you won’t even notice this new little search field in the lower right corner of your player. Enjoy playing your video…Need to do a quick search? Your fingers subconciously start typing in this little, skillfully inlayed search box. You would not even think of opening another search engine’ s window. Why bother, the search is at your fingertips! Simple and smart, as everything Google does.

The next target for Google could be something like AOL messenger. Kids and some adults spend half of their lives there. They need to stick this Google toolbar there, right under? You move the messenger window and the toolbar naturally moves with the AOL Messenger? Or Yahoo Messenger (oops…did I say something stupid here?).

Here’s a free tip for GUI design tool vendors: tweak your tool a bit to allocate a half-inch band at the bottom of each window that is created by your tool. Some time in the future your application will place the Google toolbar there. It’s just a matter of time. By reserving this little real estate in advance, you’ll save yourself hours of tedious work on moving the GUI controls around when your boss will ask you to find a room for this little extra toolbar. People purchase real estate on cemeteries in advance, right? Let’s enforce the same practice in the GUI design.

IT Career: Contractors

Once in a while I run into online discussions about working as IT contractors vs. employees. Having a decent experience wearing both hats, I decided to write several blogs on this subject. This blog is about IT contractors. Some of my comments may sound cynical to you, but this is how I see things today. This might change, if someone will give me a really good reason to do so.

1. Contractors work for money. Period. They do not have any other objectives such as creating a great software, making a career, earning a new title, or helping your firm to succeed. They work for your firm mostly because they like the rate, and in some cases, they are interested in learning technologies used in your firm. Can you have peace of mind if you spend all day working on something you do not really enjoy? In a perfect world, people will work on very interesting and well paid jobs. But since our world is not perfect, work on the interesing stuff after hours for free. This hobby may turn into a paid job in the future.

2. Most contractors work with their clients through another firm that was lucky to get on the client “s preferred vendors list. Such firms are often referred as pimps, which does not mean that contractors do not like them. Over the years, experienced contractors create their private lists of reputable pimps and maintain friendly relations with them.

3. In terms of paying taxes, contractors (in the USA) can work in various ways , for example “on W2 form rdquo;, which means that the pimp pays your taxes: you’ll receive the net income according to your tax brackets. Creating your own corporation can be more rewarding in terms of taxes, and in the industry jargon , this way of working is called “corp-to-corp “. There are some other ways of working, for example “on 1099 form rdquo;, when you are a sole proprietor (a.k.a. independent contractor). Here’s another term: “contract-to-hire “. This is also called “try-and-buy “: sometimes, the client company wants to try you as a contractor first, and then convert you to an employee, if they like you. If this is does not meet your career objective, either do not take this contract, or negotiate upfront if working as a contractor only is an option.

Most likely people use other forms of businesses too, i.e. LLC, but I “m not an accountant and can “t talk about those.

4. There is an opinion that working directly with the client is better than going through the pimp. This is not necessarily true. For example, if your direct client goes out of business, you “ll never receive your last check(s). I “ve been in such situation myself, and my lawyer said, “You can “t get blood from the stone rdquo;. In this regard, pimps are more reliable parties to deal with.

5. How much client pays to your pimp for your services? Typically your pimp enjoys a 15-30% markup. The larger the pimp, the higher this number. Is this a reasonable amount? Try not to worry about it. Your rate should be your only concern. You do not like it? Try to find a better rate somewhere else. Can “t do? Sit down and shut up. Welcome to capitalism.

6. Hire a professional accountant to do your taxes. Never try to save money by filing your taxes with the help of this inexpensive software. Reputable accountants know how to save your money based on the current tax laws in your geographical

area.

7. Is it ethical to terminate your contract before it ends? Yes it is, but play by the rules: always give a two-week notice to your client. The client may not be as nice to you and can kick you out without any warning at any moment. This is not typical but happens. I remember, when I was signing my very first contract with a large Wall Street firm, I did not like the clause that I “d have to give a notice but the client could have terminated the contract at any moment without explaining the reason. I was trying to fight, and the client “s manager pointed at their open-space floor with lots of people working there and said, “Half of these people are lawyers. Do you think you have a chance to win if something goes wrong? No way. If everything goes well, we’ll always give you an advanced notice “. This put my mind at ease.

8. Does your client like you? Your manager likes you because you help him/her to complete the project in time, which means that you help is his/her career. Your peers don “t like you, because they suspect that you earn a lot more than them, do not have to put up with the corporate politics, et al. They may respect you though for your expertise. Sort of a necessary evil.

9. Why companies hire these expensive contractors? Here “s the short answer is: they need a person (a.k.a. resource) with a specific set of skill for a short period of time. I “ve explained it in more details over here.

10. Should you work as a contractor? Yes, if the following statements are true:

Your title is not important to you

You like to have a chance to work with different technologies

You enjoy the learning process, and prefer to keep your technical skills current

You hate corporate politics

You like meeting new people and work in different environments

Neither you nor any of your immediate family members need good medical coverage

11. To have an idea about contructors’ rates, check out this Web site.

In the future blogs of this series, I “ll write about surviving in a corporate world as an employee, comparing earning, dealing with annual reviews, writing resumes, passing job interviews, outsourcing effects, etc.

To be continued hellip;