Che voi sappiate c'è un modo o sapete come fare a dare una priorità ad un Thread?
Io ho un thread che ha bisogno di una priorità alta, perchè ha il compito di suonare un effetto ogni tot tempo (fino ad un minimo di un decimo di secondo) solo che, sfruttando il Thread.sleep(), non è sempre preciso, e in piu se si usa contemporaneamente qualcos'altro, tipo cambiare la pagina della Home, mi crea un lag.
Il codice nel punto cruciale è questo (Lo posto in caso sto cappellando qualcosa):
L'applicazione è questa:codice:private void ciclaDurata(Durata temp){ long durataIntermedia, tempoNow; pauseTotal = 0; durataIntermedia = durataTotale; timeStart = tempoNow = SystemClock.elapsedRealtime(); timeTemp = ((Durata)temp).getDurata(); while( tempoNow -(timeStart+pauseTotal) <= timeTemp){ if (currentStatus == PAUSE){ } else if (currentStatus == STOP){ break; } else if (currentStatus == RUNNING) { try { Thread.sleep(70); } catch (InterruptedException e) { e.printStackTrace(); } tempoNow = SystemClock.elapsedRealtime(); durataTotale = durataIntermedia + tempoNow -timeStart-pauseTotal; updateListenerTick(); } } if (currentStatus != STOP){ durataTotale = durataIntermedia + timeTemp; updateListenerTick(); if (onCall){ int how; try{ how = Integer.parseInt(howToPlayOnCalling); } catch (NumberFormatException ex){ how = 0; } switch(how){ case 0: suoni.playSound(((Durata)temp).getIdBell()); break; case 1: suoni.playLowSound(((Durata)temp).getIdBell()); case 2: break; } } else { suoni.playSound(((Durata)temp).getIdBell()); } } }