home *** CD-ROM | disk | FTP | other *** search
/ Chip 1995 March / CHIP3.mdf / programm / prog4 / answers / ch24_2.ada < prev    next >
Encoding:
Text File  |  1991-07-01  |  2.1 KB  |  90 lines

  1.                         -- Chapter 24 - Programming exercise 2
  2. with Text_IO; use Text_IO;
  3.  
  4. procedure CH24_2 is
  5.  
  6.    package Int_IO is new Text_IO.Integer_IO(INTEGER);
  7.    use Int_IO;
  8.  
  9. begin
  10.  
  11.    for Index in 1..4 loop
  12.       delay 0.5;
  13.       Put_Line("This is in the main program.");
  14.    end loop;
  15.  
  16.    declare
  17.       task First_Task;
  18.       task Second_Task;
  19.       task Third_Task;
  20.  
  21.       task body First_Task is
  22.       begin
  23.          for Index in 1..4 loop
  24.             delay 0.0;
  25.             Put_Line("This is in First_Task.");
  26.          end loop;
  27.       end First_Task;
  28.  
  29.       task body Second_Task is
  30.       begin
  31.          for Index in 1..4 loop
  32.             delay 0.0;
  33.             Put_Line("This is in Second_Task.");
  34.          end loop;
  35.       end Second_Task;
  36.  
  37.       task body Third_Task is
  38.       begin
  39.          for Index in 1..8 loop
  40.             delay 0.0;
  41.             Put_Line("This is in Third_Task.");
  42.          end loop;
  43.       end Third_Task;
  44.    begin
  45.       delay 0.0;
  46.       Put_Line("This is in the block body.");
  47.       delay 0.0;
  48.       Put_Line("This is also in the block body.");
  49.    end; -- of declare
  50.  
  51.    for Index in 1..4 loop
  52.       delay 0.5;
  53.       Put_Line("This is at the end of the main program.");
  54.    end loop;
  55.  
  56. end CH24_2;
  57.  
  58.  
  59.  
  60.  
  61. -- Result of Execution
  62.  
  63. -- This is in the main program.
  64. -- This is in the main program.
  65. -- This is in the main program.
  66. -- This is in the main program.
  67. -- This is in First_Task.
  68. -- This is in Second_Task.
  69. -- THis is in the block body.
  70. -- This is in Third_Task.
  71. -- This is in First_Task.
  72. -- This is in Second_Task.
  73. -- This is also in the block body.
  74. -- This is in Third_Task.
  75. -- This is in First_Task.
  76. -- This is in Second_Task.
  77. -- This is in Third_Task.
  78. -- This is in First_Task.
  79. -- This is in Second_Task.
  80. -- This is in Third_Task.
  81. -- This is in Third_Task.
  82. -- This is in Third_Task.
  83. -- This is in Third_Task.
  84. -- This is in Third_Task.
  85. -- This is at the end of the main program.
  86. -- This is at the end of the main program.
  87. -- This is at the end of the main program.
  88. -- This is at the end of the main program.
  89.  
  90.