Basic HTML version of Foils prepared July 6 99

Foil 48 Introducing Threads

From Use of Java Language in Computational Science DoD Modernization Users Group Conference Monterey -- June 7 99. by Nancy McCracken, Geoffrey C. Fox


1 One way to create threads is to write a separate class that subclasses the Thread class.
2 The main line of execution is put in a method called run(), which overrides the method of the same name from the Thread class.
3 Instances of this subclass are created like this:
  • MyThread mt = new MyThread( );
4 Thread control:
  • When the thread is created, it does not automatically start running. The class that creates it must call the Thread method start(). mt.start ( );
  • Other methods may be called: Thread.sleep( ), Thread.yield( ), suspend( ), resume( ), stop( ), and join( ).

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Jul 6 1999