-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.java
More file actions
45 lines (41 loc) · 864 Bytes
/
Stack.java
File metadata and controls
45 lines (41 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
public class Stack extends Thread{
Queue queue;
String array[];
int ctr = 0;
Thread t;
public Stack(int size){
queue = new Queue(size);
array = new String[size];
}
public void push(String string){
array[ctr++] = string;
// System.out.println(string);
queue.enqueue(string);
}
public String pop(){
--ctr;
return queue.dequeue();
}
public boolean isEmpty(){
return ctr == 0;
}
public void print(){
// System.out.print("STACK: ");
// for(int i = 0; i < array.length; i++){
// if(array[i] != null){
// System.out.print(array[i]);
// try{
//
// Thread.sleep(500);
// }catch(Exception e){
//
// } }
// }
// try{
// Thread.sleep(1000);
// }catch(Exception e){}
//
// System.out.println();
queue.print();
}
}