Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set global max_connections = 200;
- public class ParserMain {
- public static void main(String[] args) throws java.io.IOException {
- // Общее число сообщений
- int total_entries = 12000;
- // Кол-во потоков
- int thread_count = 25;
- // Кол-во записей на поток
- int entries_thread = total_entries / thread_count;
- // Начальный инкремент потока
- int thread_end;
- // Конечный инкремент потока
- int thread_start;
- for (int i = 1; i <= thread_count; ++i) {
- thread_end = i * entries_thread;
- thread_start = thread_end - entries_thread;
- new ParserThread(thread_start, thread_end).start();
- }
- }
- }
- public class ParserThread extends Thread {
- private int jstart;
- private int jend;
- protected Connection conn;
- protected PreparedStatement ps;
- protected Statement st;
- protected ResultSet rs;
- public ParserThread(int jstart, int jend) {
- this.jstart = jstart;
- this.jend = jend;
- }
- public void run() {
- String dbDriver = "org.gjt.mm.mysql.Driver";
- String dbHost = "jdbc:mysql://localhost/test?autoReconnect=true";
- try {
- Class.forName(dbDriver);
- conn = DriverManager.getConnection(dbHost, "root", "");
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement