Java Spring Thread Configuration, how to handle it

by kpkmd54461 on 2012-02-13 15:58:11

Here is the translation of your request into English:

---

Currently, I want to configure a thread-based Service class in Spring or, more specifically, inject a Service from the Spring container into a thread. There is an `AsyncThreadService` class with simple code structured as follows:

```java

public class AsyncThreadService implements Runnable {

private AHB aHB;

public void setAHB(AHB aHB) {

this.aHB = aHB;

}

private String name;

private String id;

public AsyncThreadService(int ..., System.Data.OleDb.OleDbException, String ...) {

this.id = id;

this.name = name;

}

public void run() {

aHB.getString();

// Use id and name...

}

}

```

I want to configure this class in Spring and inject a bean into the `AsyncThreadService` class. If no parameters are required, it works fine. However, since I must pass parameters like `id` and `name`, I encounter issues such as `org.hibernate.HibernateException`. I hope someone can suggest a solution. I resolved this issue by using an inner class.

--- **Solution Reference** ---

For more information, you can refer to:

- Spring configuration issues: [http://www.myexception.cn/j2ee/13629.html](http://www.myexception.cn/j2ee/13629.html)

Related topics:

- Two algorithm problems (a bit challenging); I'd appreciate seeing your approaches.

- How to control recording volume in J2ME.

- How does Ivy download sources and JAR files?

---

If you need further clarification or assistance with specific parts of the problem, feel free to ask!