      program main

      integer threadcounter(10)
      common /problem/ threadcounter
      external subr2

      nthreads= 2

      call t_init(0,0)

c Spawn helper compute thread if required.
      if ( nthreads .gt. 1 ) then
         do i= 2, nthreads
            threadcounter(i)= i
            call create( threadcounter(i), subr2, ierr )
            write(0,*) "cm: === spawned helper thread", i, ierr
         enddo
      endif

      call subr2(1)
      call sleep(3)
      call t_shutdown
      stop
      end

      subroutine subr2(mythread)
      character*80 c
      write(0,*) 'thread ',mythread,' in subr'
      if ( mythread.eq.1 ) then
         read(5,*) c
      endif

      write(0,*) 'thread ',mythread,' calling abarrier'
      call abarrier(mythread)
      write(0,*) 'thread ',mythread,' through barrier'
      call sleep(2)
      return
      end

