List of usage examples for java.lang InterruptedException printStackTrace
public void printStackTrace()
From source file:Producer.java
public synchronized void run() { for (int i = 0; i < 10; i++) { try {// w w w .jav a 2 s . c om int j = deque.takeLast(); deque.remove(); System.out.println(name + " takes " + j); Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:Producer.java
public synchronized void run() { for (int i = 0; i < 10; i++) { try {/*ww w. j av a 2s .co m*/ deque.putFirst(i); System.out.println(deque.size()); System.out.println(name + " puts " + i); Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:Producer.java
public synchronized void run() { for (int i = 0; i < 10; i++) { try {//from ww w . j ava 2 s .c om int j = deque.takeLast(); System.out.println(deque.peek()); System.out.println(name + " takes " + j); Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:ExchangerProducer.java
public void run() { while (true) { try {//from w w w. j a v a 2 s .c om System.out.println("Producer."); Thread.sleep(1000); fillBuffer(); System.out.println("Producer has produced and waiting:" + buffer); buffer = exchanger.exchange(buffer); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:ExchangerProducer.java
public void run() { while (true) { try {/* ww w. ja va2 s. c om*/ System.out.println("Consumer."); buffer = exchanger.exchange(buffer); System.out.println("Consumer has received:" + buffer); Thread.sleep(1000); System.out.println("eating:" + buffer); buffer.clear(); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:Producer.java
public synchronized void run() { for (int i = 0; i < 10; i++) { try {//from w w w . java 2s . c o m deque.putFirst(i); System.out.println(name + " puts " + i); Thread.sleep(300); } catch (InterruptedException e) { e.printStackTrace(); } } }
From source file:ThreadState.java
public void run() { while (keepRunning) { synchronized (syncObject) { if (wait) { try { syncObject.wait();// www. j a v a 2s. co m } catch (InterruptedException e) { e.printStackTrace(); } } } } }
From source file:net.nikey.utils.NikeySecurityTest.java
@Override public void run() { String currentThreadName = Thread.currentThread().getName(); System.out.println("currentThreadName : " + currentThreadName); ////from w ww.ja va2s. c om Random random = new Random(); int age = random.nextInt(100); NikeySecurity.setUser(age + "", "" + age); System.out.println("thread " + currentThreadName + " first read name is:" + NikeySecurity.getName()); try { Thread.sleep(1000); } catch (InterruptedException ex) { ex.printStackTrace(); } System.out.println("thread " + currentThreadName + " second read name is:" + NikeySecurity.getName()); try { Thread.sleep(1000); } catch (InterruptedException ex) { ex.printStackTrace(); } System.out.println("third " + currentThreadName + " third read name is:" + NikeySecurity.isSignedIn()); }
From source file:net.yacy.yacy.java
/** * Submits post data to the local peer URL, authenticating as administrator * @param homePath directory containing YaCy DATA folder * @param path url relative path part//from www.ja v a 2 s . co m * @param processdescription description of the operation for logging purpose * @param post data to post */ private static void submitPostURL(final File homePath, final String path, final String processdescription, final Map<String, ContentBody> post) { final Properties config = configuration("COMMAND-STEERING", homePath); // read port final int port = Integer.parseInt(config.getProperty(SwitchboardConstants.SERVER_PORT, "8090")); // read password final String encodedPassword = config.getProperty(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""); final String adminUser = config.getProperty(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"); // send 'wget' to web interface final HTTPClient con = new HTTPClient(ClientIdentification.yacyInternetCrawlerAgent); // con.setHeader(requestHeader.entrySet()); try { /* First get a valid transaction token using HTTP GET */ con.GETbytes("http://localhost:" + port + "/" + path, adminUser, encodedPassword, false); if (con.getStatusCode() != HttpStatus.SC_OK) { throw new IOException("Error response from YACY socket: " + con.getHttpResponse().getStatusLine()); } final Header transactionTokenHeader = con.getHttpResponse() .getFirstHeader(HeaderFramework.X_YACY_TRANSACTION_TOKEN); if (transactionTokenHeader == null) { throw new IOException("Could not retrieve a valid transaction token"); } /* Then POST the request */ post.put(TransactionManager.TRANSACTION_TOKEN_PARAM, UTF8.StringBody(transactionTokenHeader.getValue())); con.POSTbytes(new MultiProtocolURL("http://localhost:" + port + "/" + path), null, post, adminUser, encodedPassword, false, false); if (con.getStatusCode() >= HttpStatus.SC_OK && con.getStatusCode() < HttpStatus.SC_MULTIPLE_CHOICES) { ConcurrentLog.config("COMMAND-STEERING", "YACY accepted steering command: " + processdescription); } else { ConcurrentLog.severe("COMMAND-STEERING", "error response from YACY socket: " + con.getHttpResponse().getStatusLine()); try { HTTPClient.closeConnectionManager(); } catch (final InterruptedException e1) { e1.printStackTrace(); } RemoteInstance.closeConnectionManager(); System.exit(-1); } } catch (final IOException e) { ConcurrentLog.severe("COMMAND-STEERING", "could not establish connection to YACY socket: " + e.getMessage()); try { HTTPClient.closeConnectionManager(); } catch (final InterruptedException e1) { e1.printStackTrace(); } RemoteInstance.closeConnectionManager(); System.exit(-1); } try { HTTPClient.closeConnectionManager(); } catch (final InterruptedException e) { e.printStackTrace(); } RemoteInstance.closeConnectionManager(); // finished ConcurrentLog.config("COMMAND-STEERING", "SUCCESSFULLY FINISHED COMMAND: " + processdescription); }
From source file:com.ling.spring.task.FixedDelayTask.java
@Scheduled(fixedDelay = 5000) public void runTask() { System.out.println("fixedDelay run..." + format.format(new Date())); try {/*from w w w . j a v a 2s . c o m*/ Thread.currentThread().sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } }