- (void)compute:(NSNumber *)aObject
{
double sum = 0;
for (int a = aObject.intValue; a < n ; a++)
{
sum = sum + a;
// [self print:a];
}
[self performSelectorOnMainThread:@selector(updateLabel:) withObject:[NSNumber numberWithDouble:sum] waitUntilDone:NO];
}
//group
dispatch_group_t group = dispatch_group_create();
dispatch_group_async(group, queue, ^{
double sum = 0;
for (int a = i; a < n ; a++)
{
sum = sum + a;
}
NSLog(@"queue 1 = %f",sum);
});
dispatch_barrier_async(queue, ^{
double sum = 0;
for (int a = i; a < n ; a++)
{
sum = sum + a;
}
NSLog(@"barrier = %f",sum);
});
dispatch_group_async(group, queue, ^{
double sum = 0;
for (int a = i; a < n ; a++)
{
sum = sum + a;
}
NSLog(@"queue 2 = %f",sum);
});
dispatch_group_async(group, queue, ^{
double sum = 0;
for (int a = i; a < n ; a++)
{
sum = sum + a;
}
NSLog(@"queue 3 = %f",sum);
});