# Implementing @WorkflowInterface

**URL:** <https://community.temporal.io/t/implementing-workflowinterface/2846>\
**Category:** Community Support\
**Tags:** general-impl\
**Created:** [September 1, 2021, 9:59pm UTC](https://community.temporal.io/t/implementing-workflowinterface/2846 "2021-09-01T21:59:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonyantony](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/sonyantony/32/1209_2.png) [@sonyantony](https://community.temporal.io/u/sonyantony)\
**Post date:** [September 1, 2021, 9:59pm UTC](https://community.temporal.io/t/implementing-workflowinterface/2846/1 "2021-09-01T21:59:12Z")

</div>

1. can a single class implement multiple workflow types ? ( multiple @WorkflowInterface )
2. What will happen if there are multiple classes implementing the same @WorkflowInterface
3. Will the implementing class get instantiated for each new workflow ? ( or it Temporal going to call the @WorkflowMethod on the same instance whenever a new workflow is created )
4. Are there any requirements on the constructor of the implementing class ? ( Like there should be a default constructor )
5. is it OK for the implementing class to have static block with code inside it ? ( java )
6. is it OK for the implementing class to have instance initializer block ? ( java )

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [September 2, 2021, 3:43am UTC](https://community.temporal.io/t/implementing-workflowinterface/2846/2 "2021-09-02T03:43:45Z")

</div>

1. Technically yes, but I don’t think this is very useful as you have to pick a single interface when creating a WorkflowStub. Workflow interface inheritance is probably more useful: [Workflows in Java | Temporal documentation](https://docs.temporal.io/docs/java/workflows#workflow-interface-inheritance)
2. Not sure what you mean with what will happen? You cannot register the same workflow type more than once with the same worker. You could register however each of the implementations of the same workflow interface with different workers listening to different task queues.
3. Temporal provides isolation of workflow executions, so each execution has its own workflow thread.
4. Yes, public no-arg constructor is needed. You should not really define a constructor on your implementations anyways. If you need to pass data to a workflow on invocation, you pass it to its @WorkflowMethod.
5. You can have non-static fields without worrying about isolation issues. For static fields you should use WorkflowLocal or WorkflowThreadLocal depending on your use case. Workflow code has to be deterministic and you can read about workflow implementation constraints [here](https://docs.temporal.io/docs/java/workflows#workflow-implementation-constraints).
6. You can but the workflow stub is created for the workflow interface and not the implementation, so no need to use them.

---

<div class="post-metadata">

**Author:** ![sonyantony](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/sonyantony/32/1209_2.png) [@sonyantony](https://community.temporal.io/u/sonyantony)\
**Post date:** [September 3, 2021, 3:43am UTC](https://community.temporal.io/t/implementing-workflowinterface/2846/3 "2021-09-03T03:43:27Z")

</div>

Thank you Tihomir.

1. I was asking this question because I thought **worker.registerWorkflowImplementationTypes(MyWfImplClass.class )** will throw an exception if MyWfImpl.class implements multiple **WorkflowInterface** interfaces

2. Does Temporal allow Java ThreadLocal objects to be attached inside the workflow ? Will it be recreated if the Worker crashes and is restarted ?

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [September 3, 2021, 2:34pm UTC](https://community.temporal.io/t/implementing-workflowinterface/2846/4 "2021-09-03T14:34:22Z")

</div>

1. It should not throw an error. You can test it yourself as well. You can have for example:

```auto
class MyWorkflowImpl implements WorkflowOneInterface, WorkflowTwoInterface { ...}

```

and then later:

```auto
WorkflowOne workflow1 = client.newWorkflowStub(WorkflowOneInterface.class, parentWorkflowOptions);
WorkflowTwo workflow2 = client.newWorkflowStub(WorkflowTwoInterface.class, parentWorkflowOptions);

```

1. If you use the WorkflowLocal and WorkflowThreadLocal provided by the SDK your workflows will be deterministic and replayable
