Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.mycompany.app22;
- public class MyPrintTask implements Runnable {
- private int m;
- private long etime;
- public MyPrintTask(int m) {
- this.m = m;
- }
- @Override
- public void run() {
- final long ctime = System.currentTimeMillis();
- try {
- for (int i = m; i >= 0; i--) {
- //System.out.println(m);
- System.out.println("MyPrintTask (" + Thread.currentThread().getName() + ")" + i);
- try {
- Thread.sleep(2000);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- }
- } finally {
- etime = System.currentTimeMillis() - ctime;
- }
- }
- //
- public long getExecutionTime() {
- return etime;
- }
- public int getM() {
- return m;
- }
- public void setM(int m) {
- this.m = m;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement