Right. Now that you know how to do this, you can use Java Interfaces whenever you need to. To be honest, the text above doesn't quite work with the current version of AppletMagic. Instead of doing:
  My_Thread : Thread_Ptr := new_Thread(X.Runnable'Access);

You need to do this:

  My_Thread : Thread_Ptr := new_Thread(Runnable_Ptr'(X.Runnable'Access));

It turns out that in the currently-available version of AppletMagic there is an ambiguity in the "new_Thread" method. The problem is that there are several "new_Thread" operations that take one parameter, and they're ambiguous enough that the Ada compiler can't determine which one to call. The "Runnable_Ptr'(" stuff tells the Ada compiler that the parameter enclosed is of type "Runnable_Ptr", which is enough to enable the code to be compiled.

You may go to the next section.

You may also:

PREVIOUS Go back to the question

OUTLINE  Go up to the outline of lesson 16

David A. Wheeler (dwheeler@dwheeler.com)

The master copy of this file is at "http://www.adahome.com/Tutorials/Lovelace/s16s7r3.htm".