Salve raga il mio giochino per la scuola consiste nel cliccare tutti i quadratini che si visualizzano sullo schermo sl che il problema è che pultroppo con i thread mi rallenta xkè dovrei creare tanti thread quanti i quadratini.. potete consigliarmi?...
Classe che crea 1 bottone e 1 thread
-------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Quad extends JButton implements Runnable {

private static Visiva1 vis;
private static Delay d;
private boolean clicked=true;

/**
* Method Quad
*
*
*/
public Quad(Visiva1 vis) {
super();

this.vis=vis;
this.setEnabled(false);
this.addActionListener(new GestoreVisiva1(this,this.vis));
this.setBackground(Color.BLACK);
}
/*public void start ()
{
t.start();
}*/

public void setDelay (long millisec)
{
this.d=new Delay(millisec);
}
public void run ()
{
this.clicked=true;
this.setEnabled(true);
this.setBackground(Color.green);
this.d=new Delay(500);
d.start();
while (d.check ());
if (this.clicked)
{
this.setBackground(Color.yellow);
this.d=new Delay(500);
d.start();
while (d.check ());
if (this.clicked)
{
this.setBackground(Color.red);
this.d=new Delay(500);
d.start();
while (d.check ());
}
}
this.setBackground(Color.black);
if (this.clicked)
{
this.vis.addScore(-5);
this.vis.loadLevel();
}
---------
gestione dei pulsanti e futuro main

import javax.swing.*;
import java.awt.*;

public class Visiva1 extends Gioco {

/*
protected JFrame mainGame = new JFrame();
protected Rules r = new Rules();
protected static int score = 0;
protected Timer60s tempo = new Timer60s();
protected int lvl;
*/
private Quad vett[]=new Quad[48];
private Thread v2[]=new Thread[48];
private int n=1;

/**
* Method Visiva1
*
*
*/
public Visiva1()
{
//caricamento


this.r.setText("regolamenti/visiva1.txt");

this.mainGame.setDefaultCloseOperation
(JFrame.DO_NOTHING_ON_CLOSE);

this.mainGame.setLayout(new GridLayout(6,8));

this.mainGame.setSize(800,600);

for (int i=0;i<48;i++)
{
vett[i]=new Quad(this);
this.mainGame.add(vett[i]);
}
}

/**
* Method play
*
*
*/
public void play() {
this.r.setVisible(true);
while(this.r.getLetto());
this.loadLevel();
this.mainGame.setVisible(true);
this.tempo.start();
while(this.tempo.check());
this.mainGame.setVisible(false);
}
/**
* Method loadLevel
*
*
*/
public void loadLevel()
{
n=(int)(lvl/(10*n))+1;
for (int i=0;i<48;i++)
if ((vett[i].getBackground()!=Color.black)&&(n>1))
n--;
int pos=(int)(Math.random()*48);
for(int i=0;i<n;i++)
{
do
pos=(int)(Math.random()*48);
while (vett[pos].getBackground()!=Color.black);
this.v2[pos]= new Thread(vett[pos]);
this.v2[pos].start();
}
}



}
altri metodi e classi non immesse perchè se no sarebbe un casino