You are on page 1of 1

public class ejemploRunnable implements Runnable{

@Override
public void run() {
for (int i = 0; i < 3; i++) {
manejador.post(new Runnable() {
@Override
public void run() {

r1=genera.nextInt(6);
r2=genera.nextInt(6);
dado2.setImageResource(imgs[r2]);
dado1.setImageResource(imgs[r1]);
suma = (r1+1)+(r2+1);
cont++;
if(cont%3==0){
if(suma==7||suma==11){
//Toast.makeText(MainActivity.this, "Haz gando", Toast.LENGTH_SHORT).show();
}else if (suma==2||suma==3||suma==12){
//Toast.makeText(MainActivity.this, "Haz perdido",
Toast.LENGTH_SHORT).show();
}else{
//Toast.makeText(getBaseContext(),"Sigue tirando",Toast.LENGTH_SHORT).show();
}
Toast.makeText(MainActivity.this, ""+suma, Toast.LENGTH_SHORT).show();
}

});
Log.d(TAG,"Hilo inciado "+i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}

}
}

You might also like