List of usage examples for java.lang Thread start
public synchronized void start()
From source file:edu.gmu.isa681.server.Main.java
public static void main(String[] args) { log.info("Starting server..."); final Server server = new Server(Constants.SERVER_PORT); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { server.shutdown();/* w w w.j ava 2s . co m*/ } }); Thread thread = new Thread(server, "ServerThread"); thread.start(); try { thread.join(); } catch (InterruptedException ex) { log.error(ex); } //TODO: implement some CLI to admin the server }
From source file:ThreadDemo.java
public static void main(String args[]) throws Exception { Thread t = new Thread(new ThreadDemo()); // this will call run() function t.start(); // waits for this thread to die t.join();/*from w ww .j a va 2 s.c om*/ // tests if this thread is alive System.out.println("status = " + t.isAlive()); }
From source file:com.apress.prospringintegration.channels.messagingtemplate.Main.java
public static void main(String[] args) { String contextName = "messaging-template.xml"; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); applicationContext.start();/*from w ww .j a v a 2 s .c o m*/ ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); TicketReceiver ticketReceiver = applicationContext.getBean(TicketReceiver.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); List<Ticket> tickets = ticketGenerator.createTickets(); for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); } Thread consumerThread = new Thread(ticketReceiver); consumerThread.start(); }
From source file:com.apress.prospringintegration.channels.prioritychannel.Main.java
public static void main(String[] args) { String contextName = "priority-channel.xml"; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); applicationContext.start();/*from www.j a va 2 s. c o m*/ PriorityProblemReporter problemReporter = applicationContext.getBean(PriorityProblemReporter.class); PriorityTicketReceiver ticketReceiver = applicationContext.getBean(PriorityTicketReceiver.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); List<Ticket> tickets = ticketGenerator.createTickets(); for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); } Thread consumerThread = new Thread(ticketReceiver); consumerThread.start(); }
From source file:com.apress.prospringintegration.channels.queuechannel.EmergencyTicketMain.java
public static void main(String[] args) { String contextName = "queue-channel-emergency-handling.xml"; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); applicationContext.start();/*from ww w .ja va2s. c o m*/ ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); EmergencyTicketReceiver ticketReceiver = applicationContext.getBean(EmergencyTicketReceiver.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); List<Ticket> tickets = ticketGenerator.createTickets(); for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); } Thread consumerThread = new Thread(ticketReceiver); consumerThread.start(); }
From source file:com.apress.prospringintegration.channels.queuechannel.TicketMain.java
public static void main(String[] args) { String contextName = "queue-channel.xml"; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); applicationContext.start();// ww w . j av a 2 s .co m ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); TicketReceiver ticketReceiver = applicationContext.getBean("ticketReceiver", TicketReceiver.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); List<Ticket> tickets = ticketGenerator.createTickets(); for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); } Thread consumerThread = new Thread(ticketReceiver); consumerThread.start(); }
From source file:com.apress.prospringintegration.channels.rendezvouschannel.Main.java
public static void main(String[] args) throws Throwable { String contextName = "rendezvous-channel.xml"; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); applicationContext.start();/* www .ja v a 2s . c o m*/ ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); TicketReceiver ticketReceiver = applicationContext.getBean(TicketReceiver.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); // start *before* message publication because it'll block on put Thread consumerThread = new Thread(ticketReceiver); consumerThread.start(); List<Ticket> tickets = ticketGenerator.createTickets(); for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); } }
From source file:Main.java
public static void main(String[] args) { Main temp = new Main(); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(temp);//from w ww. j ava 2 s . c om frame.pack(); frame.setVisible(true); Thread updater = new Thread(temp.new CustomThread()); updater.start(); }
From source file:DaemonThread.java
public static void main(String[] args) { System.out.println("entering main()"); Thread t = new Thread(new DaemonThread()); t.setDaemon(true);// w w w . ja va2s . c o m t.start(); try { Thread.sleep(3000); } catch (InterruptedException x) { } System.out.println("leaving main()"); }
From source file:org.apigw.authserver.RemoteCalendar.java
public static void main(String[] args) throws Exception { for (int i = 0; i < 5; i++) { System.out.println("Starting thread: " + i); Thread t = new Thread(new Testing(i)); t.start(); }//from ww w. j av a2 s . co m }