240103 JAVA Queue01
2024. 1. 3. 18:11ㆍ2023.11.21-2024.05.31
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
|
package com.sukgi.thread;
import java.util.LinkedList;
import java.util.Queue;
class Message{
public String command;
public String to;
public Message(String command, String to) {
this.command = command;
this.to = to;
}
}
public class Queue01 {
public static void main(String[] args) {
//Queue<Integer> queue = new LinkedList<Integer>();
Queue<Message> messageQueue = new LinkedList<Message>();
messageQueue.offer(new Message("sendMail", "홍길동"));
messageQueue.offer(new Message("sendSMS", "김길동"));
messageQueue.offer(new Message("sendKakaotalk", "최길동"));
while(!messageQueue.isEmpty()) {
Message msg = messageQueue.poll();
System.out.println(msg.command + " : " + msg.to);
}
}
}
|
cs |
sendMail : 홍길동
sendSMS : 김길동
sendKakaotalk : 최길동
'2023.11.21-2024.05.31' 카테고리의 다른 글
240103 JAVA Stack (0) | 2024.01.03 |
---|---|
240103 JAVA Inner (0) | 2024.01.03 |
240103 JAVA Thread (2) | 2024.01.03 |
231228 HTML BoardDAO.java (0) | 2024.01.02 |
231228 HTML BoardDTO.java (0) | 2024.01.02 |