How can I distinguish a winner in this thread race? - java

I have been writing a race code for a class I am in that races two threads, a tortoise and a hare. I can get both of them to run for 80 units but I don't know how to write a code that determines and outputs who the winner is. Any help would be appreciated because I am super new to coding.
I have the tortoise, hare, and raceParticipant classes. My driver class looks like this, where I would assume I put the winner code?
package Domain;
public class Driver
{
public static void main(String[] args)
{
Hare bob = new Hare();
Tortoise fred = new Tortoise();
int winDistance = 80;
do {
bob.sprint();
fred.sprint();
bob.display();
fred.display();
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
}while(bob.getTotalDistance() < winDistance && fred.getTotalDistance() < winDistance);
}
}
My sprint method is
public int sprint()
{
int sleep = generator.nextInt(100);
int sprintDistance = 0;
if (sleep > sleepPercent)
{
sprintDistance = generator.nextInt(topSpeed) + 1;
}
totalDistance +=sprintDistance;
return sprintDistance;
}

I don't see you creating a new thread anywhere.
You can create a Hare class like this:
public class Hare implements Runnable {
private static final int SLEEP_DURATION = 3000; //milliseconds
private static final int SPEED = 3; //units per second
private int distanceToRun;
private final RaceFinishListener listener;
public Hare(int distanceToRun, RaceFinishListener listener) {
this.distanceToRun = distanceToRun;
this.listener = listener;
}
#Override
public void run() {
do {
distanceToRun -= SPEED;
try {
Thread.sleep(SLEEP_DURATION);
} catch (InterruptedException e) {
e.printStackTrace();
}
} while (distanceToRun > 0);
listener.onRaceFinished(getClass().getSimpleName());
}
}
and a similar Tortoise class with these variables:
private static final int SLEEP_DURATION = 1000; //sleeps less
private static final int SPEED = 1; //but is slow
Then create a listener to get notified when someone has finished:
public interface RaceFinishListener {
void onRaceFinished(String finisher);
}
and finally your main class:
public class Test implements RaceFinishListener {
private String winner;
private static final int DISTANCE_TO_RUN = 10;
public static void main(String[] args) {
new Test().race();
}
private void race() {
Hare bob = new Hare(DISTANCE_TO_RUN, this);
Tortoise fred = new Tortoise(DISTANCE_TO_RUN, this);
new Thread(bob).start();
new Thread(fred).start();
}
#Override
public void onRaceFinished(String finisher) {
synchronized (this) {
if (winner == null) {
winner = finisher;
System.out.println(finisher + " is the winner!");
} else {
System.out.println(finisher + " lost.");
}
}
}
}
Output
Tortoise is the winner!
Hare lost.

After this line:
}while(bob.getTotalDistance() < winDistance && fred.getTotalDistance() < winDistance);
You would just have:
boolean bobWins = (bob.getTotalDistance() >= winDistance);
boolean fredWins = (fred.getTotalDistance() >= winDistance);
if (bobWins && fredWins) {
System.out.println("It's a tie");
}
else if (bobWins) {
System.out.println("Bob Wins");
}
else {
System.out.println("Fred Wins");
}

Related

Print Zero Even Odd Multithreading Java

I am trying to solve the issue, but the program only shows the below output and halts.
My question is: why the notifiall() call in printZero() does not result in releasing the wait on other threads?
Output: Waiting evenWaiting oddZero0notified
Program:
package com.leetcode.problems;
import java.util.ArrayList;
import java.util.List;
public class PrintZeroEvenOdd {
private class Printer {
int temp= 0;
int i = 0;
List list = new ArrayList();
public synchronized void printZero(){
if((temp) > 0 || temp < 0){
try{
wait();
} catch(InterruptedException e){
}
}
System.out.print("Zero" + 0);
if(temp%2 == 0){
temp = temp -1;
} else if(temp%2 == 1){
temp = 1 - temp;
}
i++;
notifyAll();
System.out.print("notified");
}
public synchronized void printOdd(){
if(( temp == 0 || (temp % 2) == 0)){
try{
System.out.print("Waiting odd");
wait();
} catch(InterruptedException e){
}
}
System.out.println("Odd"+i);
temp = 1- temp;
i++;
notifyAll();
}
public synchronized void printEven(){
if(( temp == 0 || (temp % 2) == 1)){
try{
System.out.print("Waiting even");
wait();
} catch(InterruptedException e){
}
}
System.out.println("Even"+i);
temp = temp -1;
i++;
notifyAll();
}
}
transient int i = 0;
private class ZeroPrinter implements Runnable{
Printer printer ;
ZeroPrinter( ){
printer = new Printer();
}
#Override
public void run(){
while(i<20)
printer.printZero();
}
}
private class OddPrinter implements Runnable{
Printer printer ;
OddPrinter( ){
printer = new Printer();
}
#Override
public void run(){
while(i<20)
printer.printOdd();
}
}
private class EvenPrinter implements Runnable{
Printer printer ;
EvenPrinter(){
printer = new Printer();
}
#Override
public void run(){
while(i<20)
printer.printEven();
}
}
public static void main(String[] argw) throws InterruptedException{
PrintZeroEvenOdd printZeroEvenOdd = new PrintZeroEvenOdd();
Thread printEvenThread = new Thread(printZeroEvenOdd.new EvenPrinter());
Thread printZeroThread = new Thread(printZeroEvenOdd.new ZeroPrinter());
Thread printOddThread = new Thread(printZeroEvenOdd.new OddPrinter());
printEvenThread.start();
Thread.sleep(1000);
printOddThread.start();
Thread.sleep(100);
printZeroThread.start();
}
}
Each Thread is synchronizing (holding the lock) on its own instance of Printer (as you are creating a new Printer instance in each of the 3 constructors), so notifyAll() doesn't result in the other threads waking up, since they are waiting on different monitors (difference object instances of Printer).
The printZeroThread is printing the output that you see because it's never entering the condition if((temp) > 0 || temp < 0).
I am not sure exactly what your program is trying to achieve, but it surely seems like it should be working on a single instance of Printer.
It seems that, in your private classes you should remove the new Printer() and use the enclosing class instead, for example in Zero printer I've commneted out the parts that needs to be removed:
private class ZeroPrinter implements Runnable{
// Printer printer ;
// ZeroPrinter( ){
// printer = new Printer();
// }
#Override
public void run(){
while(i<20)
// printer.
printZero();
}
}
The same should be done for EvenPrinter and OddPrinter, then these private classes will use the encolsing instace of Printer, so there will be one monitor common for these instances.
Sure, Here is the Program as corrected :-
package com.leetcode.problems;
import java.util.ArrayList;
import java.util.List;
public class PrintZeroEvenOdd {
private class Printer {
int temp = 2;
int i = 0;
List list = new ArrayList();
public Printer() {
};
public synchronized void printZero() {
while (i < 19) {
if ((temp) == 0) {
try {
wait();
} catch (InterruptedException e) {
}
}
System.out.print(0);// System class is a final class , and thus
// only one threead will take control
temp = 0;
i++;
notifyAll();
// System.out.print("notified");
}
}
public synchronized void printOdd() {
while (i < 19) {
if (((temp) != 0)) {
try {
wait();
} catch (InterruptedException e) {
}
}
if ((i % 2) == 1) {
System.out.println(i);
notifyAll();
}
temp = 1;
}
}
public synchronized void printEven() {
while (i < 19) {
if (temp != 0) {
try {
// System.out.print("Waiting even");
wait();
} catch (InterruptedException e) {
}
}
if ((i % 2) == 0) {
System.out.println(i);
notifyAll();
}
temp = 1;
}
}
}
transient int i = 0;
private class ZeroPrinter implements Runnable {
Printer printer;
ZeroPrinter(Printer printer) {
this.printer = printer;
}
#Override
public void run() {
printer.printZero();
}
}
private class OddPrinter implements Runnable {
Printer printer;
OddPrinter(Printer printer) {
this.printer = printer;
}
#Override
public void run() {
printer.printOdd();
}
}
private class EvenPrinter implements Runnable {
Printer printer;
EvenPrinter(Printer printer) {
this.printer = printer;
}
#Override
public void run() {
printer.printEven();
}
}
public static void main(String[] argw) throws InterruptedException {
PrintZeroEvenOdd printZeroEvenOdd = new PrintZeroEvenOdd();
Printer printer = printZeroEvenOdd.new Printer();
Thread printEvenThread = new Thread(printZeroEvenOdd.new EvenPrinter(
printer));
Thread printZeroThread = new Thread(printZeroEvenOdd.new ZeroPrinter(
printer));
Thread printOddThread = new Thread(printZeroEvenOdd.new OddPrinter(
printer));
// Above order does not matter
// In short , in MT Order to start the threads does not matter at all
printEvenThread.start();
Thread.sleep(1000);
printOddThread.start();
Thread.sleep(100);
printZeroThread.start();
}
}

Print Floyd triangle using multithreading in java

I want to use two threads to print Floyd triangle(say one thread prints the number and the other prints the number in the line) as below.
and so forth until the max number which is 15 in this case.
I tried following but it keeps on printing numbers one on each line
public class MyThread extends Thread{
static volatile int lineNumber = 1;
public static void main(String... args) {
PrintFloyd print = new PrintFloyd();
Thread t1 = new Thread(new TaskHandler(print, 10), "T1");
Thread t2 = new Thread(new TaskHandler(print, 10), "T2");
t1.start();
t2.start();
}
}
class TaskHandler implements Runnable {
static volatile int i = 1;
static volatile int lineCount = 1;
static volatile int lineNumber = 1;
private int max;
private PrintFloyd print;
TaskHandler(PrintFloyd print2, int max) {
this.print = print2;
this.max = max;
}
#Override
public void run() {
System.out.println(">>>>" + Thread.currentThread().getName());
while(i < max){
if (Thread.currentThread().getName().equals("T1")){
print.printNumber(i);
} else {
print.breakLine();
}
}
}
}
class PrintFloyd {
boolean isBreakPoint = false;
public void printNumber(int i) {
synchronized(this){
while (isBreakPoint == false) {
try {
wait();
} catch (InterruptedException ex) {
}
System.out.print(i++ + " ");
isBreakPoint = false;
notifyAll();
}
}
}
public void breakLine(){
synchronized(this){
while (isBreakPoint == true) {
try {
wait();
} catch (InterruptedException ex) {
}
}
System.out.println();
isBreakPoint = true;
notifyAll();
}
}
}
The following code would help:
public class PrintPatternWith2Threads {
final static int MAX = 15;
final static String itemWriterName = "itemWriter";
final static String newLineWriterName = "newLineWriter";
public static void main(String[] args) {
Printer print = new Printer(MAX);
Thread itemWriter = new Thread(new ItemWriter(print), itemWriterName);
itemWriter.start();
Thread newLineWriter = new Thread(new NewLineWriter(print), newLineWriterName);
newLineWriter.start();
}
}
class ItemWriter implements Runnable {
private Printer print;
ItemWriter(Printer print) {
this.print = print;
}
public void run() {
while (print.current <= print.MAX) {
print.printNumber();
}
}
}
class NewLineWriter implements Runnable {
private Printer print;
NewLineWriter(Printer print) {
this.print = print;
}
public void run() {
while (print.current <= print.MAX) {
print.printNewLine();
}
}
}
class Printer {
public final int MAX;
public int current = 1;
public int itemsInALine = 1;
Printer(int max) {
this.MAX = max;
}
public void printNumber() {
synchronized(this) {
for(int i = current; i < current + itemsInALine && i <= MAX; i++) {
System.out.print(i + " ");
}
this.current = current + itemsInALine;
itemsInALine++;
notifyAll();
try {
if(this.current < MAX) {
wait();
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public void printNewLine() {
synchronized(this) {
System.out.println();
notifyAll();
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

Playing random pairs of words in Sound Arrays

My goal is to play doublets (pairs) of the phrase "This is a test", which is a WAV audio file. So far I succeeded in generating a random sequence of the phrase, such as "Test is this a", but I need to make it so that it only speaks in pairs, so "This is"... "Is a"... with a 100 m.second pause between each word and a 400 m.second pause between each pair. This is what I have thus far...
public void playDoublets(int numDoublets) throws InterruptedException {
ArrayList<Sound> list = new ArrayList();
for (int i =0; i < numWords; i++){
list.add(new Sound(myWordArray[i]));
}
Collections.shuffle(list);
for (int i = 0; i < numWords; i++){
list.get(i).blockingPlay();
Thread.sleep(400);
}
}
numDoublets is how many pairs the program plays, but I do not know where I would implement it in the code above. All this code does so far is just print out all 4 words, but not in pairs.
You should explicitly represent a pause in your list of sounds you want to play. Use an interface to generically handle both normal sounds and pauses.
import java.util.*;
public class DoubletPlayer {
private static final int PAUSE_BETWEEN_WORDS = 100;
private static final int PAUSE_BETWEEN_DOUBLETS = 400;
public static void main(String... args) {
DoubletPlayer player = new DoubletPlayer();
player.playDoublets(2);
}
interface Playable {
void play();
}
class Sound implements Playable {
private String word;
public Sound(String word) {
this.word = word;
}
#Override
public void play() {
System.out.println("sound played: " + word);
}
}
class Pause implements Playable {
private int millis;
public Pause(int millis) {
this.millis = millis;
}
#Override
public void play() {
System.out.println("pause of " + millis + "ms");
}
}
private List<Sound> sounds = new ArrayList<>();
private int currentSound = 0;
public DoubletPlayer() {
sounds.add(new Sound("This"));
sounds.add(new Sound("is"));
sounds.add(new Sound("a"));
sounds.add(new Sound("test"));
Collections.shuffle(sounds);
}
public void playDoublets(int numDoublets) {
List<Playable> doublets = generateDoublets(numDoublets);
playAll(doublets);
reset();
}
private List<Playable> generateDoublets(int numDoublets) {
List<Playable> result = new ArrayList<>();
for (int i = 0; i < numDoublets; i++) {
addDoubletTo(result);
}
return result;
}
private void addDoubletTo(List<Playable> result) {
result.add(getNextSound());
result.add(new Pause(PAUSE_BETWEEN_WORDS));
result.add(getNextSound());
result.add(new Pause(PAUSE_BETWEEN_DOUBLETS));
}
private Playable getNextSound() {
return sounds.get(currentSound++);
}
private void playAll(List<Playable> result) {
for (Playable playable : result) {
playable.play();
}
}
private void reset() {
currentSound = 0;
}
}

javax.sound.sampled - trying to start audio sample repeatedly doesn't work

I am programming a little drum sequencer, a roland tr808 knockoff with 16 steps/measure and 16 instruments(=drum samples). User has a gui where he can thus create a 16x16 pattern.
However, if a sample is played more than once in quick succession, it often just gets played once. Say, I got a bassdrum on step 1, 5, 9 and 13 and tempo's 130BPM, it sometimes plays just the bd on 1 and 9, and sometimes the ones on 5 and/or 13 as well. If the sample is very short or the tempo is slow, the chances are higher that every step in the pattern is played correctly. So I assume that the audio line doesn't like it when I try to play a sample again when it hasn't finished yet.
But actually I thought I'd taken that into account in my code. I'd be really thankful if someone told me what's wrong with my code.
Here's my complete code as suggested by Andrew Thompson, modified so that it takes some samples from the internet. Loading them takes a bit, though. the part causing the issue is probably the play() method in the Instrument class:
package testbox;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.sound.sampled.*;
public class boomboxtest {
public static void main(String[] args) {
Sequencer seq = new Sequencer();
//bassdrum
seq.toggleInstrument(0,0);
seq.toggleInstrument(0,4);
seq.toggleInstrument(0,8);
seq.toggleInstrument(0,12);
//snare
seq.toggleInstrument(1,4);
seq.toggleInstrument(1,12);
//Hihat
seq.toggleInstrument(2, 2);
seq.toggleInstrument(2, 6);
seq.toggleInstrument(2, 10);
//Bongo
seq.toggleInstrument(3, 6);
seq.toggleInstrument(3, 10);
seq.setTempo(130);
seq.play();
}
}
class Sequencer {
private Mixer mixer;
private List<SequencerListener> listeners = new ArrayList<SequencerListener>();
public static final int INSTR_COUNT = 4;
private int tempo_bpm = 120;
private ExecutorService executor;
private int current_step = 0;
private int current_max_step = 16;
private boolean[][] pattern = new boolean[32][INSTR_COUNT];
private ArrayList<Instrument> instruments;
Line[] lines = new Line[16];
private SequencerEngine seq;
private String[] filenames = {"http://www.canadianmusicartists.com/sample/kick_02.wav", "http://www.canadianmusicartists.com/sample/snare01.wav", "http://www.canadianmusicartists.com/sample/H_closedhat_01.wav", "http://www.canadianmusicartists.com/sample/bongo01.wav"};
public Sequencer() {
seq = new SequencerEngine();
try{
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
mixer = AudioSystem.getMixer(mixerInfo[0]);
} catch (Exception e) {e.printStackTrace();}
instruments = new ArrayList<Instrument>(INSTR_COUNT);
for (int i = 0; i < INSTR_COUNT; i++) {
System.out.println("Loading instrument " + i);
Instrument instr = new Instrument(filenames[i], mixer);
instruments.add(instr);
lines[i] = instr.getLine();
}
syncMixer();
executor = Executors.newCachedThreadPool();
executor.submit(seq);
}
public void syncMixer() {
if (mixer.isSynchronizationSupported(lines, false)) {
mixer.synchronize(lines, false);
} else {
System.out.println("No hay synchronisado");
}
}
public boolean isPlaying() {
return seq.getRunning();
}
public boolean toggleInstrument (int instrument, int beat) {
pattern[beat][instrument] = !pattern[beat][instrument];
return pattern[beat][instrument];
}
public void play() {
seq.toggleRun(true);
}
public void pause() {
seq.toggleRun(false);
}
public void stop() {
pause();
setCurrent_step(0);
}
public int getTempo() {
return tempo_bpm;
}
public void setTempo(int tempo) {
if (tempo < 30) {
tempo = 30;
} else if (tempo > 200) {
tempo = 200;
} else {
this.tempo_bpm = tempo;
}
}
public int getCurrent_step() {
return current_step;
}
public void setCurrent_step(int current_step) {
this.current_step = current_step;
}
public boolean[][] getPattern() {
return pattern;
}
public void kill() {
seq.kill();
executor.shutdownNow();
}
public void addListener(SequencerListener toAdd) {
listeners.add(toAdd);
}
public class SequencerEngine implements Runnable{
private boolean running;
private boolean alive = true;
public void run() {
while( getAlive()) {
while (getRunning()) {
if (current_step >= current_max_step) {
current_step = 0;
}
for (; current_step < current_max_step ; current_step++) {
stepListen();
if(!getRunning()) {
break;
}
long time = System.currentTimeMillis();
long steptime = 60000/(4*tempo_bpm);
for (int k = 0; k < INSTR_COUNT; k++) {
if (pattern[current_step][k]) {
instruments.get(k).play();
}
}
while((System.currentTimeMillis()-time) < steptime) {}
}
}
}
}
public void stepListen() {
for (SequencerListener sl : listeners) {
sl.stepEvent(current_step);
}
}
public boolean getRunning() {
return running;
}
public boolean getAlive() {
return alive;
}
public void toggleRun(boolean toggle) {
running = toggle;
}
public void kill() {
alive = false;
}
}
}
class Instrument {
private String name;
private File soundFile;
private AudioInputStream stream;
private AudioFormat format;
private DataLine.Info info;
private Clip clip;
private Mixer mixer;
public Instrument(String filename, Mixer mixer ) {
this.name = filename;
try {
//soundFile = new File("sounds/" + filename);
URL url = new URL(filename);
this.mixer = mixer;
//stream = AudioSystem.getAudioInputStream(soundFile);
stream = AudioSystem.getAudioInputStream(url);
format = stream.getFormat();
info = new DataLine.Info(Clip.class, format);
clip = (Clip) mixer.getLine(info);
clip.open(stream);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void play() {
clip.stop();
clip.setFramePosition(0);
clip.start();
}
public Line getLine() {
return clip;
}
}
interface SequencerListener {
void stepEvent(int current_step);
}
The samples are of rather questionable quality, but especially the bassdrum sample illustrates my problem really good.

Scheduling Two Separate Timers in Java and changing Period of one timer

I have two Timers in java that are scheduled independently. Both timers have different Task.
Timer 1 increments a number and Timer 2 changes the period of Timer 1. Here is the code where I am using two timers
public class Receiver
{
public static int totalBufferCapacity = 1024;
public static int totalPacketsDropped = 0;
public static int totalPacketsServiced = 0;
public static int totalPacketsReceived = 0;
public static int timesBufferGetsFull = 0;
public static int timesIntervelChanged = 0;
public static Socket clientSocket;
public static BufferedReader br;
public static ArrayList<String> buffer;
public static String START = "Start";
public static String STOP = "Stop";
public static String token = "1";
public static boolean flag;
public static Timer timer;
public static int Max = 80;
public static int Min = 40;
public static int rand;
public static PrintStream ps;
public static String packet;
public static Timer timer_2;
public static consumeArrayItems task;
public static void main(String[] args)
{
flag = true;
try
{
init(args[0], args[1]);
while (flag)
{
storePacketInArray();
}
} catch (Exception e)
{
e.printStackTrace();
}
}
public static void init(String localHost, String portNumber)
{
try
{
// inet address which is local host in this case
InetAddress acceptorHost = InetAddress.getByName(localHost);
// port number at which the sender wants to communicate
int serverPortNum = Integer.parseInt(portNumber);
clientSocket = new Socket(acceptorHost, serverPortNum);
} catch (IOException e)
{
e.printStackTrace();
}
}
public static void storePacketInArray()
{
try
{
if (br == null)
{
br = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
}
packet = new String(br.readLine());
if (packet.compareToIgnoreCase("Start") == 0)
{
token = START;
buffer = new ArrayList<String>(totalBufferCapacity);
} else if (packet.compareToIgnoreCase("Stop") == 0)
{
stopVaryingTimeSchedular();
stopSchedular();
} else
{
totalPacketsReceived += 1;
buffer.add(packet);
}
computeToken();
} catch (IOException e)
{
e.printStackTrace();
}
}
public static void computeToken()
{
int bufferSize = buffer.size();
if (bufferSize > 0 && bufferSize < totalBufferCapacity)
{
float queueOccupancy = (bufferSize * 100 / totalBufferCapacity);
} else if (bufferSize == totalBufferCapacity)
{
token = "10";
timesBufferGetsFull += 1;
} else if (token.compareToIgnoreCase("Start") == 0)
{
token = START;
startSchedular();
startVaryingTimeSchedular();
} else
{
totalPacketsDropped += 1;
token = "15";
}
sendAcknowledgment();
}
public static void sendAcknowledgment()
{
try
{
if (ps == null)
{
ps = new PrintStream(clientSocket.getOutputStream());
}
String tokenAck = token;
if (packet.compareToIgnoreCase("Stop") != 0)
{
ps.println(tokenAck);
ps.flush();
}
if (!flag)
{
clientSocket.close();
}
} catch (IOException e)
{
e.printStackTrace();
}
}
public static void startSchedular()
{
rand = (int) (Math.random() * (Max - Min));
timer = new Timer();
task = new consumeArrayItems(true);
timer.scheduleAtFixedRate(task, 1, rand);
}
public static void stopSchedular()
{
timer.cancel();
timer.purge();
flag = false;
}
// After every 500 ms service time of packets will vary between Max and Min
public static void startVaryingTimeSchedular()
{
timer_2 = new Timer();
timer_2.scheduleAtFixedRate(new varyServiceTime(), 0, 500);
}
public static void stopVaryingTimeSchedular()
{
timer_2.cancel();
timer_2.purge();
}
}
class consumeArrayItems extends TimerTask
{
public synchronized void run()
{
if (Receiver.buffer.size() > 0)
{
Receiver.totalPacketsServiced += 1;
Receiver.buffer.remove(Receiver.buffer.size() - 1);
}
}
}
class varyServiceTime extends TimerTask
{
public synchronized void run()
{
Receiver.timer.cancel();
Receiver.timer = null;
Receiver.rand = (int) (Math.random() * (Receiver.Max - Receiver.Min));
Receiver.timer = new Timer();
Receiver.timer.scheduleAtFixedRate(new consumeArrayItems(), 0,Receiver.rand);
Receiver.timesIntervelChanged += 1;
}
}
Timer 2 never gets scheduled. What wrong I am doing here.

Categories