SpringBoot中使用新執行緒傳送郵件

2021-09-24 19:53:14 字數 355 閱讀 9266

由於郵件的傳送是乙個阻塞操作,因此我將之放到子執行緒中完成,因此我需要在springboot中配置乙個執行緒池,如下:

@bean

public executorservice executorservice()

在配置類中提供上面這個bean即可,然後在需要用的地方將之注入即可:

@autowired

executorservice executorservice;

然後使用:

executorservice.execute(new emailrunnable(employee));

在新執行緒中使用NSTimer

方法一 void viewdidload void call1 void call2 方法二 void bool animated void timerstart void bool animated 方法三 timer nstimer timerwithtimeinterval 5.0 targe...

Toast 新執行緒及Service中使用方法

1.新執行緒中使用需要先呼叫looper.prepare 新建乙個looper物件 looper物件生成時會生成乙個訊息佇列 而toast的顯示是需要訊息佇列的 例子 looper.prepare toast.maketext looper.loop 2.service中使用toast 必須是與se...

Spring Boot中使用MongoDB資料庫

前段時間分享了關於spring boot中使用redis的文章,除了redis之後,我們在網際網路產品中還經常會用到另外一款著名的nosql資料庫mongodb。下面就來簡單介紹一下mongodb,並且通過乙個例子來介紹spring boot中對mongodb訪問的配置和使用。mongodb是乙個基...