Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Qore

(SMP threaded scripting language)

Date:07/11/12
Author:Brett Estrade
URL:n/a
Comments:0
Info:http://www.qore.org
Score: (1.50 in 2 votes)
#!/usr/bin/env qore                                                                        
                                                                                           
%require-our                                                                               
%enable-all-warnings                                                                       
%require-types                                                                             

# make sure we have the right version of qore
%requires qore >= 0.8.3
    
# no gui
%no-gui                                                                                    

# global variables (truly shared among threads) must be declared with "our" keyword
%require-our

our Counter $count();

sub t() {
  on_exit { 
        $count.dec();
  }
  my int $i = gettid()-1;
  printf("%d bottles of beer on the wall\n", $i);
  printf("%d bottles of beer\n", $i);
  printf("take one down, pass it around\n");
  printf("%d bottles of beer on the wall\n", $i);
}

#-- following run by main thread
for (my int $i = 99; $i > 0; $i--)  {
  $count.inc();
  background t();
}

$count.waitForZero();

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
1Brett Estrade07/11/120

Comments

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: