How to access a Runnable object by Thread?

前端 未结 11 924
深忆病人
深忆病人 2020-12-08 10:21

Possible duplicate: need-help-returning-object-in-thread-run-method

Hello. I have a class implementing runnable and I have a List, storing Threads instantiated with

11条回答
  •  青春惊慌失措
    2020-12-08 11:17

    To give a concrete example of Paul Crowley's solution, I think this is what he suggests:

    public class BackgroundJob extends Thread {
    
        private final JOB mJob;
    
        public BackgroundJob(JOB job) {
            super(job);
            mJob = job;
        }
    
        public JOB getJob() {
            return mJob;
        }
    
    }
    

提交回复
热议问题