Asynchronous Message Passing in JR

We've now covered the basic synchronization systems (semaphore, monitors) and we know how to declare operations and capabilities . It's time to go to an other form of synchronization : Message Passing. In this post, we'll focus in Asynchronous Message Passing, we'll cover later, the synchronous message passing system with RendezVous.

When we use message passing, the threads doesn't share datas anymore, they share channels. You can see channels like an abstraction of a network between several processes. The processes will send messages to other and the other will wait for receive a message. Normally, with that form of synchronization, the channels are the only objects shared between the threads. So you doesn't need to share memory. That makes possible to distribute the processes across several virtual machines or computers, of course, this also works on a simple computer, like any other program. In message passing, we often see models with several clients and a server that manage the messages.

Read more…

JR Operations and Capabilities

Now that we've seen how to use semaphores and monitors in JR, we must go to message passing. But before, we must learn how to use operation and capabilities in JR. These concepts are used in JR to message passing, so we must learn them before.

An operation (or op-method) has the same form as a method declaration but are declared with a op keyword. An operation can be invoked the same way as a normal method or can be invoked with a call statement (also with a send statement as we'll see in next post about JR).

Read more…

Monitor programming in JR

Like I promised, I will restart to write articles now that the evaluation period is over.

After seeing how to develop using the JR programming language, we'll see now how to use monitors in JR.

Monitors provide a higher-level abstraction than semaphores and produce a better code with several advantages :

  • All the synchronization code is centralized in one location and the users of this code doesn't need to know how it's implemented.
  • The code doesn't depends on the number of processes, it works for as much process as you want
  • You doesn't need to release something like a mutex, so you cannot forget to do it

The mutual exclusion is implicit with monitors. Only one process is allowed in the monitor, so all the method are automatically guarded with synchronization code. The synchronization between threads is made using signaling system, with condition variables. A condition variable is a kind of queue of process who are waiting on the same condition. You have several operations available on a condition, the most important is to signal a process waiting to be awaken and to wait on a condition. There are some similitudes between signal/wait operations and P and V of semaphores, but this is a little different. The signal operation does nothing if the queue is empty and the wait operation put always the thread in the waiting queue. The process queue is served in a first come, first served mode.

Now we'll see how to use them in JR.

Read more…

Wordpress 3.0 installed !

Wordpress 3.0 (Thelounious) has been released this week. I just updated the blog with the new version. I had no problem during the upgrade process, all automatically. Good job !

This major release of Wordpress solve more tan 1200 bug, add several performance improvements and add several new features :

  • Merge of Wordpress MU : You can now add several different blogs on the same installation of Wordpress
  • New default Theme : Twenty Ten
  • Bulk updates for the plugins. You can updates all your plugins and themes at once.
  • More possibilities for the themes : custom background, headers, shortlinks, ...
  • Custom post types
  • Lighter interface

If you want more information, this video can help you :

JTheque is migrating to Git

Some informations about the current state of JTheque. I'm currently migrating it from SVN to Git. Actually the projet is hosted at Developpez.com, a french community. For more visibility, i wanted to host it in an english website. After several days of comparative, I chosen Github has host. Because i chose Git, i think it's the best and easier community to share projects using Git.

I will use a subdomain in this website (jtheque.baptiste-wicht.com) to host the Javadoc and maven reports, because it take too space to store it at GitHub. I will use GitHub for the sources, issues and Wiki.

After only several days of work with Git, I found it really fun and comfortable to work with.

Here are the already created projects on GitHub :

Most of them are not completed at all. But the start is here. Don't hesitate to comment on how I did that. I've also already created a site for jtheque-xml-utils (http://jtheque.baptiste-wicht.com/xml-utils/).

I will migrate all the projects into Git and complete the GitHub repositories and Maven Site the next few weeks.

If I didn't post a lot these last weeks, it's because, it's the end of the semester, so it seems a lot of exams and projects to finish, so not a lot of time to post. I will do better the next month.

How to choose a monitor for your computer ?

The monitor is a very important part of your computer. Indeed without it you cannot display anything. There is several types of monitors and the price varying a lot. The most limiting criteria will be your budget when you've to choose a new monitor.

In this post, we'll see what to watch before buying a new monitor.

Read more…

Java 7 : Translucency and shaped windows

Java 7 introduces very interesting features for desktop windows :

  • Transclucency for windows : Make a full window translucent with a specified alpha level
  • Per pixel translucency : Make a part of the window translucent.
  • Shaped windows : You can now create windows with a certain shape, like circle, ovale, triangle, ...

We'll see all this features in that post. All the examples are tested in Windows Seven 64 bits, because the transclucency isn't supported in Ubuntu 10.04 at the time I write the article.

Read more…

Java 7 : Add "public defender methods" to Java interfaces

At this time, we aren't sure that the closures will be included in the Java 7 release. But these doubts have generated a new project : The "public defender methods" proposal.

This new proposal for Java 7 wants to improve the interfaces allowing to add new methods to existing interfaces. The classes implementing the interfaces doesn't need implements these methods. The implementation of these methods are provided using static methods. This could be called virtual extension method.

Read more…

Java 7 : Oracle pushes a first version of closures

2 days ago, Oracle pushed a first version of the closures implementation. We can see the evolving syntax in the test cases they made for the Java compiler. You can see these test cases here.

This revision supports the following features (copied from revision) :

  • Function types syntax
  • Function types subtyping
  • Full support for lambda expression of type 1 and 2
  • Inference of thrown types/return type in a lambda
  • Lambda conversion using rules specified in v0.1.5 draft
  • Support references to 'this' (both explicit and implicit)
  • Translation using method handles

The function types aren't enabled by default, so you have to use -XDallowFunctionTypes to enable it.

Here are some examples of lambda expression of type 1 taken from the test cases :

int i1 = #()(3).(); //i1 = 3
Integer i2 = #()(3).(); //i2 = 3
int i3 = #(int x)( x + 1 ).(3); //i3 = 4
int i4 = #(Number x)(x.intValue()).(new Float(3.0f)); //i4 = 3

And with type 2 :

int i1 = #(){ return 3; }.(); //i1 = 3
Integer i2 = #(){ return 3; }.(); //i2 = 3
int i3 = #(int x){ return x + 1; }.(3); //i3 = 4
int i4 = #(Number x){ return x.intValue(); }.(new Float(3.0f)); //i4 = 3

For those who didn't understand the syntax, #(int x)( x + 1 ) declares a lambda expression that takes a int and return this int plus 1. And the . (dot) is used to invoke the lambda expression. So #(int x)( x + 1 ).(3) declares the lambda expression and invoke it with 3 as parameter.

This syntax is a little bit shocking, but I think we'll get used.

15 years birthday of Java (a bit late)

I didn't notice that earlier, but the 23 May 2010 was the 15 years birthday of Java !

I started using Java only 5 years ago, but I've always been happy of this language.

It makes now a long time that we've this wonderful language to develop :)

Thanks a lot to James Gosling and Sun Microsystems for this great language.

Duke Java Logo