Files
openide/plugins/devkit/devkit-java-tests/testData/threadingModelHelper/SubtypingPolymorphism.java
Moncef Slimani ae7ce93178 [threading] IJPL-179707: Minor bug fix and refactoring of Analyzer
GitOrigin-RevId: ca372c621f208ccba68219f8bf91e43c2958bc63
2025-11-17 13:31:32 +00:00

35 lines
757 B
Java

import com.intellij.util.concurrency.annotations.RequiresReadLock;
import com.intellij.util.concurrency.ThreadingAssertions;
public class SubtypingPolymorphism {
public void testMethod() {
Service[] services = {new FileService(), new UIService(), new DatabaseService()};
for (Service service : services) {
service.execute();
}
}
}
interface Service {
void execute();
}
class FileService implements Service {
@Override
@RequiresReadLock
public void execute() { }
}
class UIService implements Service {
@Override
public void execute() {
ThreadingAssertions.assertEventDispatchThread();
}
}
class DBService implements Service {
@Override
public void execute() {
ThreadingAssertions.assertReadAccess();
}
}