Wednesday, August 28, 2013

How synchronized methods can be ignored

Here is a question:

If an object has a synchronized method A and a not synchronized method B, can both method be called by different threads?

And the answer is:

Only one thread can access synchronized method A at a time (unless there are two different objects and each thread calls method A on different objects). B can be accesed by many threads at any given time, even when A is executing.

At the beginning I was a bit confused about the second part, if that is so, then a class might not be protected against multithreading update if it has at least one non-synchronized method that modifies an instance variable used by a synchronized method. I was right!

Here's is the code to prove it:

If you run this code it will sometimes show final value as 0 and other times value as 1. So when designing a class that should be synchronized take under consideration which methods are you leaving free that can modify instance (or static) attributes.
English Java Multithreading

Tuesday, August 13, 2013

Volunteering at Chuck Pezoldt Park

Not all is sitting behind a computer programming and publishing blog posts! ;) Sometimes is good to take fresh air and do something helpful for the community.

Last weekend as well as in the Global Youth Service Day I went with my wife to a park to plant trees (after all as José Martí once said: before die you should "Plant a tree, write a book, have a son"). It was exhausting but a fulfilling activity and it was great to see that the trees we planted months ago were healthy and still there. 

The Miami-Dade county parks workers are very nice and organized people and they had it all under control so the job was very fruitful. Specifically with this park (Chuck Pezoldt) they are improving its services and we helped them saving some money to more costly activities like installing lights or improving the sport courts in the park, while doing something good for the environment and the the community.

To learn more about this or other activities, please refer to the Parks Foundation of Miami-Dade County.

And, because not everything is hard work, I leave you with the Harlem Shake we did back in April. This video is also posted on the Parks Foundation Facebook site.

Ecology English Miami Volunteering

Thursday, August 1, 2013

How to send emails in Wordpress with Contact Form 7

Recently I was working with a client's Wordpress-based site where they had configured a contact form using Contact Form 7 to send emails to clients. I'm not going to enter in details on how to use Contact Form 7 since there are good guides in the plugin's site.

The thing is that after configuring Contact Form 7, I found issues sending emails. The Contact Form 7 owner posted a link to a blog that explained how to solve this for specific configurations using WP-Mail-SMTP plugin. This gave some guidance but I had to tweak it a lot (for example, changing from WP-Mail-SMTP to WP-SMTP) to make it work for me, and I hope with the following instructions you will be able to solve it in your site too.

First of all, my configurations:
  • Wordpress, version 3.5.2
  • Contact Form 7, version 3.4.2
  • WP-SMTP, version 1.1.5
  • The site is hosted in GoDaddy.
Notice that I use WP-SMTP instead of WP-Mail-SMTP.

First, you have to change the WP-SMTP configuration. You can do it through Settings -> WP-SMTP. Set the following:
                From: my email (ex: "")
                From Name: "Whatever you like"
                Host: localhost
                SMTP Secure: None
                Port: 25
                SMTP Authentication: No
                All the other fields empty. 

WP-SMTP Configuration

You should be able to send a test email using the fields at the bottom of the form. If this works, you're almost done!

Finally,  another problem that I found is that you cannot send empty message body in the Contact Form (notice the [your-message] value in the picture below). Based on the Contact Form Docs, I configured the contact form as shown. The field [email-88] is the name of the field email that the user introduced in the form.

The reply-to header was a nice touch that I took from Mario Varga's post.

Contact Form 7 Configuration
Hope it works for you!
English Troubleshooting Web Wordpress


Don't miss any post

Subscribe here to get new posts directly to your inbox.

Copyright © Librethinking.
Designed by Templateism. Hosted on Blogger Platform.