     public var sync: Lock {
         self.locks.main
     }
+    
+    public enum EventLoopGroupProvider {
+        case shared(EventLoopGroup)
+        case createNew
+    }
 
-    public init(_ environment: Environment = .development) {
+    public init(
+        _ environment: Environment = .development,
+        _ eventLoopGroupProvider: EventLoopGroupProvider = .createNew
+    ) {
         Backtrace.install()
         self.environment = environment
-        self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
+        self.eventLoopGroupProvider = eventLoopGroupProvider
+        switch eventLoopGroupProvider {
+        case .shared(let group):
+            self.eventLoopGroup = group
+        case .createNew:
+            self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
+        }
         self.locks = .init()
         self.userInfo = [:]
         self.didShutdown = false


public final class Application {
    public var environment: Environment
    public let eventLoopGroup: EventLoopGroup
    public var storage: Storage
    public var userInfo: [AnyHashable: Any]

        self.storage.clear()
        self.userInfo = [:]

        switch self.eventLoopGroupProvider {
        case .shared:
            self.logger.trace("Running on shared EventLoopGroup. Not shutting down EventLoopGroup")
        case .createNew:
            self.logger.trace("Shutting down EventLoopGroup")
            do {
                try self.eventLoopGroup.syncShutdownGracefully()
            } catch {
                self.logger.error("Shutting down EventLoopGroup failed: \(error)")
            }
        }

        self.didShutdown = true
