【发布时间】:2020-05-05 09:38:41
【问题描述】:
按照这段代码,如何在发送记录和获取记录之间实现多线程。
public class Test_ProducerConsumer {
// Main method
public static void main(String[] args) {
// Send records
for(int i=0; i<10; i++) {
kafka_io.send_records(sendtopic, "test_key", "test_value" + String.valueOf(i));
}
// Get records
try {
kafka_io.get_records(gettopic, 100000);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
【问题讨论】:
标签: java multithreading producer-consumer