Monday, May 3, 2010

Intermediate Java Tutorial - 27 - What do I look like, a Thread?

public class Bucky {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Tuna("one"));
        Thread t2 = new Thread(new Tuna("two"));
        Thread t3 = new Thread(new Tuna("three"));

Intermediate Java Tutorial - 26 - Learning about Threads

import java.util.*;

//Runnable interface contains run() method
public class Tuna implements Runnable{
    String name;
    int time;
    Random r = new Random();
    public Tuna(String x){
        name = x;
        time = r.nextInt(999); //between 0-1 second
    //this runs when you start thread
    public void run(){
            System.out.printf("%s is sleeping for %d\n", name, time);
            Thread.sleep(time); //how long do u want to sleep for?
            System.out.printf("%s is done\n", name);
        }catch(Exception e){}

Objective C Programming Tutorial - 27 - But what if I'm a millionaire?


@interface Person : NSObject {

int age;
int weight;
@property int age,weight;
-(void) print;

-(void) dateAge: (int) a: (int) i;



#import "Person.h"

@implementation Person

@synthesize age,weight;
-(void) print{
NSLog(@"I am %i years old and weigh %i pounds", age, weight);

-(void) dateAge: (int) a: (int) i{

NSLog(@"You can date chicks %i years old", (a/2+7)-(i/100000));




#import "Person.h"

int main (int argc, const char * argv[]) {

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

Person *bucky = [[Person alloc]init];

bucky.age = 12;

bucky.weight = 540;

[bucky print];

[bucky dateAge:45];

[bucky release];

[pool drain];

return 0;

Welcome to my new blog!

Hey everyone, welcome to my new blog. This blog isn't going to be as cool as my other one but I'm sure a lot of you guys will find it very useful. I am going to be posting all of my source code from all of the tutorials that I make form here on out on this blog. Sorry, but I don't have the source code anymore from any earlier tutorials.